Ages and durations with DATEDIF
Work out each person's whole months of service on F1, 2 Aug 2026.
keyboard Typing formulas is easiest on a computer with a keyboard.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Name | Start date | Months of service | As at | 2 Aug 2026 | ||
| 2 | Isla | 3 Feb 2017 | |||||
| 3 | Grace | 2 Aug 2018 | |||||
| 4 | Zoe | 22 Jul 2020 | |||||
| 5 | Quinn | 28 Feb 2020 | |||||
| 6 | Amara | 7 Aug 2019 | |||||
| 7 | Kofi | 31 Jul 2014 | |||||
| 8 | Felix | 29 May 2021 | |||||
| 9 | |||||||
| 10 | |||||||
| 11 | |||||||
| 12 |
How DATEDIF works
What does
DATEDIFdo?It counts the whole years, months or days between two dates. The start date goes first:
=DATEDIF(B2,$F$1, "Y") Which units are there?
- "Y": whole years, for ages and years of service.
- "M": whole months.
- "D": days, the same as subtracting.
- "YM": months left over after the whole years, so you can write "35 years, 4 months".
- "MD" and "YD": days ignoring months, or ignoring years. "MD" can give odd results at month ends, so avoid it.
Why not divide by 365?
=(F1-B2)/365drifts because of leap years and gives fractions, so someone the day before their birthday can come out a year older.YEAR(F1)-YEAR(B2)is wrong for everyone whose birthday hasn't come yet this year.DATEDIFcounts the way people do.Why isn't it in Excel's function list?
DATEDIFcame from Lotus 1-2-3 and Microsoft never documented it fully, so Excel doesn't suggest it as you type. It works in every version, and in Google Sheets.What about today's age?
Use
TODAY()as the end date:=DATEDIF(B2,TODAY(),"Y"). HereF1holds a fixed date so the answers don't change from day to day.
Know someone fighting with a spreadsheet? Send them this page.