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

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

πŸ“Ž This article includes 1 downloadable practice file ↓

⏱ 2 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. DATEDIF in practice
  7. Where you will use it
  8. Worked example
  9. Mistakes people make
  10. Related functions
  11. Continue learning

DATEDIF is a hidden function (not in the autocomplete list) that returns the difference between two dates in completed years, months or days.

Advertisement

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.

DATEDIF in practice

Where you will use it

  • Age in completed years
  • Service length for gratuity (years and months)
  • Months a loan has run

Worked example

StartEndFormulaResult
15-Aug-199004-Oct-2026=DATEDIF(A2,B2,"y")&" y "&DATEDIF(A2,B2,"ym")&" m"36 y 1 m
01-Apr-202104-Oct-2026=DATEDIF(A3,B3,"y")&" y "&DATEDIF(A3,B3,"ym")&" m"5 y 6 m
31-Jan-202601-Mar-2026=DATEDIF(A4,B4,"y")&" y "&DATEDIF(A4,B4,"ym")&" m"0 y 1 m

Results calculated in Excel.

Mistakes people make

MistakeWhat to do instead
Start after end gives #NUM!Put the earlier date first
It's not in the function listDATEDIF is hidden but works; type it fully

YEARFRAC Β· TODAY Β· EDATE

πŸ“š Part of the free Excel course: Beginner β†’ Expert Β· Try it in the Formula Lab or ask the AI Helper.

⚑ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

πŸ“Ž Practice files for this article

  • πŸ“—
    Practice workbook: Dates & times22 tasks on realistic sales data β€” type your formula, the Check column turns green when it is right. Answers sheet included.
    ⬇ XLSX Β· 34 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

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

Free Β· AI can be wrong