DATEDIF Function in Excel: Age and Tenure in Years, Months, Days

⏱ 1 min readUpdated 28 September 2026

Date & TimeLevel: IntermediateAvailable in: Excel 2007+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. Example 2
  5. Common errors and fixes
  6. 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 article

Stuck on a step? Ask a question and the AI answers using this article.

Free · AI can be wrong