The Excel DATEDIF function returns the difference between two date values in years, months, or days. The DATEDIF (Date + Dif) function is a “compatibility” function that comes from Lotus 1-2-3. For reasons unknown, it is only documented in Excel 2000, but you can use it in your formulas in all Excel versions since that time.
- Purpose: Get days, months, or years between two dates
- Return value: A number representing time between two dates
Syntax
=DATEDIF (start_date, end_date, unit)
Arguments
- start_date - Start date in Excel date serial number format.
- end_date - End date in Excel date serial number format.
- unit - The time unit to use (years, months, or days).
Example:
In the example shown above, column B contains the date January 1, 2016 and column C contains the date March 1, 2018. In column E:
E5=DATEDIF(B5,C5,"y") // returns 2
E6=DATEDIF(B6,C6,"m") // returns 26
E7=DATEDIF(B7,C7,"d")// returns 790