AnalystPracticeGuides
DashboardSign up

DATEDIF: years, months and days between two dates

DATEDIF returns the full years, months or days between two dates: =DATEDIF(start, end, unit). Excel doesn't suggest it as you type, but it works in every version.

Watch it solved. Task 8: age in full years (DATEDIF), from 5:35, in our video “Excel Interview Questions and Answers: 10 Practical Tasks, Solved”. Pressing play loads the video from YouTube (privacy). Open on YouTube

Which units can you use?

UnitReturns
"Y"complete years
"M"complete months
"D"days
"YM"months left over after full years
"MD"days left over after full months

How do you calculate age or tenure?

Birth date in B2:

=DATEDIF(B2,TODAY(),"Y")

Years and months of service, start date in C2:

=DATEDIF(C2,TODAY(),"Y")&" years, "&DATEDIF(C2,TODAY(),"YM")&" months"

What are the traps?

The start date must not be later than the end date, otherwise you get #NUM!. Microsoft warns that the "MD" unit can return wrong results in some cases, so avoid it in anything important.

Try it yourself. Practise this in a real spreadsheet in your browser, with instant feedback.
Practise DATEDIF

Updated November 2026.

← All free guides