Forum Discussion

Ajay_Anand's avatar
Ajay_Anand
Copper Contributor
Jun 01, 2019
Solved

Different results from DatedIf and DateDiff functions

I was trying to find out the difference between two dates (10-06-1985 and 01-06-2019) using these functions. DatedIf Function returned the result 33 and DateDiff function in VBA returned 34   I tho...
  • SergeiBaklan's avatar
    Jun 01, 2019

    Ajay_Anand , IMHO, they have different logic.

    DateDif calculates complete years, months, etc. Actually for your sample it'll be 33 years 11 months and some days, return for years is 33.

     

    DateDiff checks if you over the year, month, etc.

     

    For more simple example, if start date 30 Dec 2018 and end date 10 Jan 2019 when

    DateDif returns 0 years (0 years 0 months 11 days)

    DateDiff returns 1 year (you are over year 2018)

Resources