Excel DATEDIF: years, months or days between two dates
DATEDIF counts the full years, months or days between two dates. Excel hides it from the suggestions list, but it works in every version.
The formula
=DATEDIF(start_date, end_date, unit)
The start date must be the earlier one.
Steps: someone’s age
- Birth date in B1.
- Click B2. Type
=DATEDIF(B1, TODAY(), "y"). Enter.
Result: their age in full years.
The units
| Unit | Gives |
|---|---|
"y" |
Full years |
"m" |
Full months |
"d" |
Days (same as B2-B1) |
"ym" |
Months left over after the years |
"md" |
Days left over after the months |
“3 years, 4 months” in one cell
=DATEDIF(B1,B2,"y") & " years, " & DATEDIF(B1,B2,"ym") & " months"
Check it worked
Pick two dates exactly one year apart. "y" must give 1 and "ym" must give 0.
Common mistakes
#NUM! — the start date is after the end date. Swap them.
The date is text. A date typed as “12/03/2019” in a Text cell is not a date. Set the format to Date and re-enter it.
Only need days? Skip DATEDIF: subtract the dates.