Excel DATEDIF: calculate complete years, months, and days between dates
In Excel, DATEDIF gives the number of complete years or months between two dates, or the number of days elapsed. Enter the start date, end date, and unit in that order. From January 15, 2018 to June 5, 2019, the results are 1 complete year, 16 complete months, and 506 days.
Calculate years, months, and days from the same dates
Put the first two formulas in A2 and B2 to create actual dates. Enter the remaining three formulas in separate empty cells. Each uses the same two dates and changes only the unit in quotes.
=DATE(2018,1,15)
=DATE(2019,6,5)
=DATEDIF(A2,B2,"Y")
=DATEDIF(A2,B2,"M")
=DATEDIF(A2,B2,"D")
The results are 1 complete year for "Y", 16 complete months for "M", and 506 elapsed days for "D". The date difference is distinct from a count that includes both endpoints.
Check the day before an anniversary
Change B2 to January 14, 2019. The year calculation gives 0 and the month calculation gives 11. Change B2 to January 15, 2019 and the results become 1 and 12. Merely subtracting year or month numbers misses this boundary.
When the function does not appear or returns an error
Excel provides DATEDIF for compatibility with older Lotus 1-2-3 workbooks. If it does not show up in autocomplete, type the full function name yourself.
If the start date is later than the end date, the formula returns #NUM!. Check that both inputs are actual dates. Use DATE to build dates from their parts if regional settings might interpret text differently. Format the result as General or Number if it appears as a date. Use the argument separator for your regional settings.
The MD limitation and alternatives for elapsed days
Microsoft warns that the MD unit for remaining days can return a negative, zero, or inaccurate result. If you need the days after a completed month, first establish the reference date required by your rules, then subtract it from the end date. For example, choosing May 15, 2019 as the reference date gives 21 days to June 5. Decide how your rule should handle month ends and leap years.
If all you need is the difference in days, use DAYS or subtract the date cells directly.




