+ Reply to Thread
Results 1 to 10 of 10

No of months between 2 different years by year

  1. #1
    Registered User
    Join Date
    11-01-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    6

    No of months between 2 different years by year

    hi all,

    I need your help in solving the below issue.

    I have two dates in two different years. I would like to know the number of months in between the dates by year. I would explain it with an example for better understanding.

    Following are the dates that I have - 1/1/2012 & 3/2/2013.

    I can calculate the number of months between these two dates; but what I want is the numbers of months in 2012(ie - 12months) & and the number of months in 2013(3 months).


    Appreciate your help in this regard as this is really urgent

  2. #2
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: No of months between 2 different years by year

    A1 = Start Date
    B1 = End Date

    C1 = 13 - Months(A1)
    //number of months in the starting year

    D1 = MAX(( Year(B1) - Year(A1) - 1)* 12, 0)
    //number of months in the years in between start year and in year (exclusive of start and end years)

    E1 = Months (B1)
    //number of months in end year.

    Note this will treat Jan 1st and Jan 30th as being exactly the same for the purpose of counting months.

  3. #3
    Registered User
    Join Date
    11-01-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: No of months between 2 different years by year

    thanks Ben. thats works...

    Appreciate your timely help.

    Regards
    akila

  4. #4
    Registered User
    Join Date
    11-01-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: No of months between 2 different years by year

    Hi Ben,

    I have one more query.

    How can work this formula if there are more than 2 years. For eg - start date is 1/1/2011; end date is 2/1/2013. When I use the above formula i miss the months in 2012.

    Appreciate your help in this regard.

    Regards
    Akila

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: No of months between 2 different years by year

    Maybe this:
    Formula in C1

    A
    B
    C
    D
    1
    1/1/2011
    2/1/2013
    25
    =DATEDIF(A1,B1,"m")
    2
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Registered User
    Join Date
    11-01-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: No of months between 2 different years by year

    hi Alkey,

    thanks for your reply. However what I want is the number of months in each year between the dates.

    Appreciate your help.

    Regards
    Akila

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: No of months between 2 different years by year

    Try it now

    A
    B
    C
    1
    1/1/2011
    11
    =DATEDIF(A1,EOMONTH(A1,(12-MONTH(A1))),"m")
    2
    2/1/2013
    10
    =DATEDIF(A2,EOMONTH(A2,(12-MONTH(A2))),"m")
    3

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: No of months between 2 different years by year

    Try this:

    Start date in A2, end date in B2

    List all possible years in C1 across, e.g. C1 = 2010, D1 = 2011, E1 = 2012, F1 = 2013

    Now in C2 use this formula copied across

    =IFERROR(DATEDIF(MAX($A2-DAY($A2)+1,DATE(D$1,1,1)),MIN(DATE(D$1+1,1,0),$B2),"m")+1,0)
    Audere est facere

  9. #9
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: No of months between 2 different years by year

    Quote Originally Posted by AkilaAnnamalai View Post
    How can work this formula if there are more than 2 years. For eg - start date is 1/1/2011; end date is 2/1/2013. When I use the above formula i miss the months in 2012.
    Quote Originally Posted by ben_hensel View Post
    D1 = MAX(( Year(B1) - Year(A1) - 1)* 12, 0)
    //number of months in the years in between start year and in year (exclusive of start and end years)
    If you want the months per year you're going to have to set up a table first like the little spider said above me.

  10. #10
    Registered User
    Join Date
    11-01-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: No of months between 2 different years by year

    Thanks all. Your help is much appreciated.

    Regards
    Akila

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Calculating Years of Service in YEARS and MONTHS
    By joliver in forum Excel Formulas & Functions
    Replies: 24
    Last Post: 10-07-2013, 10:22 AM
  2. [SOLVED] Age based on DOB; Accounts for leap years. Years old if >2, Months if <2 years old.
    By sharpmel in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-17-2013, 04:20 PM
  3. [SOLVED] Converting negative months progress to years and months
    By drbrown14 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 11-18-2012, 05:05 PM
  4. Replies: 15
    Last Post: 12-09-2006, 05:27 PM
  5. [SOLVED] Convert Years to Years/Months/Days
    By [email protected] in forum Excel General
    Replies: 4
    Last Post: 01-04-2006, 11:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1