Article updated on February 02, 2018

The DATEDIF function returns the number of days, months, or years between two dates. The DATEDIF function exists in order to ensure compatibility with Louts 1-2-3.

Be careful with this function, there are cases where the DATEDIF may return unreliable results.

Formula in cell D3:

=DATEDIF(B3,C3,"Y")

Formula in cell D4:

=DATEDIF(B3,C3,"D")

Formula in cell D5:

=DATEDIF(B3,C3,"YD")

Formula in cell D6:

=DATEDIF(B3,C3,"M")

Formula in cell D7:

=DATEDIF(B3,C3,"MD")

Excel Function Syntax

DATEDIF(start_date,end_date,unit)

Note, this function shows no arguments in the formula bar.

Arguments

start_date Required. The beginning date of the range you want to calculate.
end_date Required. The ending date of the period.
unit Required. This determines what the function returns. See table below.

 

Unit Output
"Y" Complete years in the range.
"M" Complete months in the range.
"D" Days in the range.
"MD" Months and years of the dates are ignored. Don't use this argument, may return incorrect results.
"YM" Returns months. Days and years of the date arguments are ignored.
"YD" Returns days. The years of the date arguments are ignored.

Comments

Don't use the "MD" argument.