excelDATEDIF function


Syntax

  • =DATEDIF(start_date,end_date,unit)

Parameters

UnitReturns
"Y"The number of complete years in the period
"M"The number of complete months in the period
"D"The number of days in the period
"MD"The difference between the days in start_date and end_date. The months and years of the dates are ignored
"YM"The difference between the months in start_date and end_date. The days and years of the dates are ignored
"YD"The difference between the days of start_date and end_date. The years of the dates are ignored

Remarks

Be careful of Leap Year calculations when the units ignore years. For example:

=datedif("2010-01-01","2010-07-21","YD")

returns 201 days

=datedif("2016-01-01","2016-07-21","YD")

returns 202 days