+ Reply to Thread
Results 1 to 8 of 8

Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    71

    Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    In the attached, I've highlighted the formula in question that's seemingly comparing December to February and treating it as one month. I initially thought it was because of the number of days in Feb, but I've also highlighted in green an issue I noticed in another workbook, wherein the formula *should* return 3 months for April, May, June, but it instead returns the difference between April and June (2). Is there a catch-all solution to this inconsistency? Thanks in advance for the help!
    Attached Files Attached Files
    Last edited by Drexl27; 05-03-2024 at 12:56 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    I suspect it is because it is calculating full months

    PHP Code: 
    Unit   

    The type of information that you want returned
    where:

    Unit

    Returns

    "Y"

    The number of complete years in the period.

    "M"

    The number of complete months in the period.

    "D"

    The number of days in the period.

    "MD"

    The difference between the days in start_date and end_dateThe months and years of the dates are ignored.

    ImportantWe don't recommend using the "MD" argument, as there are known limitations with it. See the known issues section below.

    "YM"

    The difference between the months in start_date and end_date. The days and years of the dates are ignored

    "YD"

    The difference between the days of start_date and end_date. The years of the dates are ignored. 
    See: https://support.microsoft.com/en-us/...d-8b32a451b35c
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,133

    Re: Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    Why should it return 3 monts fro 30th APRIL to 30th JUNE.... 61 days in total???
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    @Glenn: it would be this:

    31/03/2024 =EOMONTH(F12, -1)
    30/06/2024 =EOMONTH(G12, 0)

    I think it might only be counting April and May. I don't think it is including the last day. Just a guess.

    01/07/2024 =EOMONTH(G12, 0)+1 gives the result = 3.
    Last edited by TMS; 04-25-2024 at 05:40 PM.

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    What I'm seeking is a formula that consistently calculates the number months *including* the start date. So if the start date is 04/30 and current date is 06/30, I want it to count that as 3 months. It works most of the time, but for some reason there are some periods between months that just don't calculate a full month and I can't figure out why.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,133

    Re: Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    You probably need:

    =DATEDIF(EOMONTH(F11, -1), EOMONTH(A5, 0)+1, "m")

    in L11 and, in K12:

    =DATEDIF(EOMONTH(F12, -1), EOMONTH(G12, 0)+1, "m")

  7. #7
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    If I'm not mistaken that adds a day. I'll run that through all my workbooks to see if this is a consistent fix - thank you!

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Issue w/ DATEDIF (Treating Dec to Feb as 1 month)

    It adds a day to the end of the month. This generates the first day of the following month, thus guaranteeing a full month.

+ 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] Datedif to count specific month
    By andsalex in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-16-2020, 10:14 AM
  2. DateDif by Month
    By Sam_Alex in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-24-2019, 11:34 AM
  3. Issue with IF and DATEDIF Formula
    By Francesco K in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-04-2018, 09:16 AM
  4. [SOLVED] DATEDIF issue
    By neelesh4 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-24-2014, 10:25 AM
  5. DATEDIF issue
    By JO505 in forum Excel General
    Replies: 3
    Last Post: 06-19-2011, 03:44 PM
  6. Month (datedif) to 1 decimal
    By jennifer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-14-2006, 03:50 PM
  7. [SOLVED] DATEDIF calculates a month off
    By Mary in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-27-2005, 07:05 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