Forum Discussion
Different results from DatedIf and DateDiff functions
- 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)
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)
SergeiBaklan Thanks for that reply.
Is there any function in VBA which equivalent to DatedIf function?
- SergeiBaklanJun 03, 2019Diamond Contributor
Ajay_Anand , I don't think so. People suggest to evaluate DateDif https://stackoverflow.com/questions/35397822/datedif-function-in-vba, but I didn't play with that.