
Date & TimeLevel: IntermediateAvailable in: Excel 2007+
In this article
- Syntax
- Examples
- Example 1
- Example 2
- Common errors and fixes
- Related functions
DATEDIF is a hidden function (not in the autocomplete list) that returns the difference between two dates in completed years, months or days.
Syntax
=DATEDIF(start_date, end_date, unit)
| Argument |
What it means |
unit |
“y” years, “m” months, “d” days, “ym” months after years, “md” days after months. |
Examples
Example 1
=DATEDIF(B2, TODAY(), "y")
Age in completed years.
Example 2
=DATEDIF(B2,TODAY(),"y")&" y "&DATEDIF(B2,TODAY(),"ym")&" m"
Tenure like “5 y 3 m”.
Common errors and fixes
| You see |
Why, and the fix |
#NUM! |
start_date is after end_date. |
💡 Microsoft warns the “md” unit can give wrong results in some cases; avoid it for critical calculations.
YEARFRAC · TODAY · EDATE
📚 Part of the free Excel course: Beginner → Expert · Try it in the Formula Lab or ask the AI Helper.
✨ Ask AI about this articleStuck on a step? Ask a question and the AI answers using this article.
Free · AI can be wrong