+ Reply to Thread
Results 1 to 7 of 7

Calculating number of Months between two dates by Year

  1. #1
    Registered User
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2003
    Posts
    4

    Calculating number of Months between two dates by Year

    Hello,

    Need help with calculating the number of months between two dates, but by year. I keep running into multiple variables when checking the formula by changing the two dates. The attached formula is what i had been working with and building on, probably need a lot more in it. I want the start date to count as 1 month as well, that is why the EOMONTH formula is their. Also was thinking I would have to make a unique formula for each specific year, that is why the first and last day of the year are their.

    Thanks for any assistance you can provide.
    Attached Files Attached Files

  2. #2
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: Calculating number of Months between two dates by Year

    Maybe put in D4 and copied cross :

    =((DAY((DATE(YEAR($B4),1+MONTH($B4),1)-1))-(DAY($B4)))/(DAY((DATE(YEAR($B4),1+MONTH($B4),1)-1))))+(DATEDIF($B4,DATE(D$3,12,1),"m")-1)+((DAY(DATE(D$3,12,1)))/(DAY(DATE(YEAR(DATE(D$3,12,1)),1+MONTH(DATE(D$3,12,1)),1)+1)))+1

  3. #3
    Registered User
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Calculating number of Months between two dates by Year

    Thanks for the reply. That formula seems to be only calculating between the start date and the end of the year. Was looking for the number of months between a start and finish date.
    I attached more of what I was looking for.

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Calculating number of Months between two dates by Year

    Try

    in D4

    =IF(YEAR($B$4)>D$3,0,IF(YEAR($B$4)=D$3,DATEDIF($B$4,EOMONTH($B$4,13-MONTH($B$4)),"m"),IF(D$3=YEAR($C$4),MONTH($C$4),IF(D$3>YEAR($C$4),0,12))))

  5. #5
    Registered User
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Calculating number of Months between two dates by Year

    Awesome. That works great for a start and finish date spanning across multiple years, but what about a start and finish date within the same year?
    Is there something to add or change in the first DATEDIF formula?

    Thanks

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Calculating number of Months between two dates by Year

    Try

    =IF(OR(YEAR($B$4)>D$3,D$3>YEAR($C$4)),0,IF(YEAR($B$4)=YEAR($C$4),MONTH($C$4)-MONTH($B$4)+1,IF(YEAR($B$4)=D$3,DATEDIF($B$4,EOMONTH($B$4,13-MONTH($B$4)),"m"),IF(D$3=YEAR($C$4),MONTH($C$4),12))))

  7. #7
    Registered User
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Calculating number of Months between two dates by Year

    that seems to do it. thank you very much!!

+ 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. Calculate number of months in a specific year between two dates.
    By chickynee in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-09-2019, 07:29 PM
  2. [SOLVED] Calculate number of months for a specific year between 2 cells with dates in them
    By accounting2015 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-25-2015, 12:22 AM
  3. [SOLVED] Calculating Number of Months between two given dates
    By InterstateRentals in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-09-2013, 10:15 AM
  4. Dates in Excel - Counting the Number of Months in a Year
    By uclaboy82 in forum Excel General
    Replies: 1
    Last Post: 06-04-2012, 11:13 PM
  5. Replies: 5
    Last Post: 06-07-2008, 02:32 PM
  6. Calculating months in year July - June
    By tuph in forum Excel General
    Replies: 7
    Last Post: 06-22-2006, 06:53 PM
  7. Calculating by individual months of the year
    By Maddoktor in forum Excel General
    Replies: 3
    Last Post: 02-08-2006, 05:00 PM

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