FormulaCamp
Completed
← All functions
Date & time

DATEDIF

Difference between dates in "y", "m" or "d" (undocumented, but works).

Syntax

DATEDIF(start_date, end_date, unit)

Example: =DATEDIF(B2,TODAY(),"y")

Available in: All versions

DATEDIF returns the number of complete years, months or days between two dates: =DATEDIF(start, end, unit), with units "y", "m", "d", "ym", "md" and "yd". It is a long-standing function that does not appear in the formula autocomplete, but it works.

When to use it

Arguments explained

Worked examples

Complete years

AB
1StartEnd
21/15/20203/20/2024

Formula: D2: =DATEDIF(A2,B2,"y")

Result: 4

From Jan 15, 2020 to Mar 20, 2024 is four complete years.

Months left over

AB
1StartEnd
21/15/20203/20/2024

Formula: D2: =DATEDIF(A2,B2,"ym")

Result: 2

"ym" ignores years and counts the whole months after the last anniversary.

Readable duration

AB
1StartEnd
21/15/20203/20/2024

Formula: D2: =DATEDIF(A2,B2,"y")&" years, "&DATEDIF(A2,B2,"ym")&" months"

Result: 4 years, 2 months

Joins two DATEDIFs into one label.

Try it

A tiny spreadsheet with example data. Edit the formula or any number and see the result.

Formula in F2: =DATEDIF(A2,B2,"m")

Example spreadsheet for DATEDIF
ABCDEF
1StartEndHolidayTimeResult
23/15/20266/20/20265/1/202614:453
31/31/20262/28/20265/9/202609:30
412/24/20251/9/2026
Result in F2: 3
Practice this in a lesson: Tenure, Deadlines, Weekdays

Common errors and how to fix them

Related functions

Frequently asked questions

How do I calculate age in Excel?
Use =DATEDIF(birth_date,TODAY(),"y").
What are the units of DATEDIF?
"y" years, "m" months, "d" days, "ym" months ignoring years, "yd" days ignoring years, "md" days ignoring months and years.
Can I use simple subtraction instead?
For days, yes: end minus start. For months and years DATEDIF counts complete periods.
Why is DATEDIF missing from the function list?
It comes from Lotus 1-2-3 compatibility and was never added to the autocomplete.

More in Date & time