Excel DATEDIF

DATEDIF measures the gap between two dates in complete years, months or days.

HR needs each employee's completed years of service. Dividing days by 365 misses leap years and gives a decimal. DATEDIF counts complete units, the way people expect an age to work, even though it doesn't appear in Excel's function list.

Practice it now

How to write it

=DATEDIF(start_date, end_date, unit)
start_date
The earlier date.
end_date
The later date.
unit
"Y" years, "M" months, "D" days.

Watch it work

E2fx 
ABCDEF
1PersonStartEnd
2Ana2020-03-152026-03-14
3Bo2024-01-102026-06-20
4
5
1

One day short of six, so it's still five.

Examples

Ana's complete years

=DATEDIF(B2,C2,"Y")5

One day short of six, so it's still five.

Bo's complete months

=DATEDIF(B3,C3,"M")29

Only full months are counted.

Bo's total days

=DATEDIF(B3,C3,"D")892

The same as subtracting the dates.

Your turn

Find Bo's complete years. Type your formula in E2.

ABCDE
1PersonStartEnd
2Ana2020-03-152026-03-14
3Bo2024-01-102026-06-20
4

Common mistakes

#NUM! error.

The start date must come first.

No autocomplete appears.

It's a hidden compatibility function, so type it in full.

Good to know

  • Use TODAY() as the end for a live age.
  • Avoid the "MD" unit, which Microsoft warns can be inaccurate.
  • DATEDIF or simple subtraction? Subtraction gives only days. DATEDIF gives complete years and months.