Excel like a finance pro.
DATEDIF
DatesWhole months and years between two dates — the function Excel hides and never autocompletes.
Difficulty
1What is it?
DATEDIF returns the complete number of years, months or days between two dates, which is how invoice age, customer tenure and asset life are actually spoken about: "4 months old", not "127 days". It's a survivor from Lotus 1-2-3, and Excel doesn't list it, doesn't autocomplete it and doesn't document it in the function browser — you have to type it in full and trust it. It still works everywhere. The unit is passed as a text code, and the three combination codes ("ym", "md", "yd") are what let you write "2 years, 4 months" without arithmetic.
2What it looks like
DATEDIF(start_date, end_date, "unit")- start_date
- The earlier date. Must not be later than end_date.
- end_date
- The later date.
- "unit"
- In quotes: "y" complete years · "m" complete months · "d" days · "ym" months ignoring years · "md" days ignoring months and years · "yd" days ignoring years.
3When you use it
- Age an invoice in whole months for an aging bucket.
- Customer or employee tenure, stated the way people say it.
- Asset age in years and months for a fixed-asset register.
4See it in action
Change the inputs — the formula and result update live. Prefer the real thing? Download the Excel file and open it in Excel.
Whole months and years, not a day count. The function Excel won't autocomplete.
=DATEDIF(B1, B2, "m") & " months old""d" — days: 166| A | |
|---|---|
| 1 | Result |
| 2 | "d" — days: 166 |
| 3 | "m" — complete months: 5 |
| 4 | "y" — complete years: 0 |
| 5 | "y" + "ym": 0 years, 5 months |
The lime cell holds the formula — click it (or any cell) to see its contents in the bar above, just like Excel. Edit the blue cells to watch it recompute.
5Common errors
#NUM!start_date is later than end_date. DATEDIF refuses to go backwards.Fix: Order the arguments, or wrap in IF to handle both directions.
The "md" unit returns something absurdIt's a known defect, not your formula — "md" can return a negative when the end day is earlier in the month than the start day.Fix: Avoid "md". Build a day remainder from the dates directly if you need one.
#NAME?The unit wasn't in quotes, or the function name is misspelled.Fix: The unit is text: "m", not m. And Excel won't autocomplete the name, so check the spelling yourself.
6Better functions & alternatives
- YEARFRAC — For a decimal fraction of a year instead of whole units.
- EDATE / EOMONTH — For moving a date by months rather than measuring between two.
Want DATEDIF already wired into a model? Wauvel's free tools download as branded, formula-driven Excel.
Learn the moves here — or let Wauvel run them on your numbers.
Meet your AI CFO →One CFO-grade Excel tip a week
A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.