DATEDIF Function
Return the number of complete years, months or days between two dates. start_date and end_date are date serial numbers or dates in text form, and unit is the kind of difference, in uppercase or lowercase: "Y" (years), "M" (months), "D" (days), "MD" (days, ignoring months and years), "YM" (months, ignoring years) or "YD" (days, ignoring years). A start date after the end date, or another unit, returns #NUM!.
Syntax
DATEDIF(start_date, end_date, unit)
Category: Date & Time. Minimum arguments: 3. Maximum arguments: 3.
Available for supported offline calculation.
Examples
=DATEDIF(DATE(2020,1,1),DATE(2026,1,1),"Y")
The formula returns 6, the complete years from January 1, 2020, to January 1, 2026.
Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.