How to work out age or years of service with DATEDIF
This counts the whole years between a start date and today, for an age from a birthday or length of service from a hire date.
The formula
=DATEDIF(B2,TODAY(),"y") in column C
What each part does
B2The earlier date.
TODAY()Today, recalculated every time the sheet opens.
"y"Answer in whole years.
How it works, and what to watch for
DATEDIF with "y" counts complete years, so someone one day short of a birthday still reads as the younger age, which is what you want.
DATEDIF is an old function that does not appear in the formula tips, but it works in every version of Excel.
For an age at a fixed date rather than today, swap TODAY() for that date.
Questions
Why can I not see DATEDIF in the suggestions?
It is a remaining from an older Excel that Microsoft never added to the tooltip list. It still works perfectly if you type it in full.
How do I get years and months?
Run DATEDIF twice, once with "y" for the years and once with "ym" for the remaining months, and join the two.
The example sheet
Staff
Joined
Years
Anne
2019-04-01
Lukas
2023-11-20
Sofia
2015-07-09
If this helped, these are close by
More on DATEDIF , and every walkthrough that uses it.
Formula List
Formula Fixer
Formula List
Settings: separator, Excel version
Argument separator
Set by your computer's language, not by the file. A frequent cause of a correct-looking formula being rejected.
Comma =SUM(A1,B1)
Semicolon =SUM(A1;B1)
Excel version
XLOOKUP, IFS, TEXTBEFORE and TEXTJOIN need Microsoft 365 or 2021; older versions return #NAME? instead. Choosing the older one switches every walkthrough to a formula that works there.
Microsoft 365 or 2021
2019 or earlier
Is a formula returning an error?
Paste it below for a line-by-line check.
Check the formula
Clear
or press Enter
Try one of these
© Formula Steps — formulasteps.com
Bookmark
Share