Months in role, not days (DATEDIF)
The problem
Problem statement
HR reports tenure in whole months, so a partial month must not round up. The start and end dates for Ana are in B2 and C2 as ISO text. Put her completed months in the Months in role cell D2.
Whole months only — a period that ends on the 14th when it started on the 15th has not gained its final month.
Problem data
Show the sheet as a table (selectable, copyable)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Employee | Start | End | Months in role |
| 2 | Ana | 2023-03-15 | 2026-01-15 | |
| 3 | Ben | 2024-07-01 | 2026-01-31 | |
| 4 | Cleo | 2025-09-01 | 2026-01-15 |
Notes
DATEDIF(start, end, "m") counts complete months between two dates. It is a compatibility function: Excel has it and never lists it in autocomplete, Google Sheets has it too. "m" gives months, "y" years, "ym" the leftover months after whole years — which is why the two-argument-chain version works.
How to approach
Your answer goes in D2. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.
- Target cell is D2
DATEDIFtakes start, end, and a unit string- The unit for whole months is "m"
- Shape:
=DATEDIF(?, ?, ?)
Official solutions
Show 2 solutions — try it yourself first
Approach 1: DATEDIF with the month unit
=DATEDIF(B2, C2, "m")
From 2023-03-15 to 2026-01-15 is 34 complete months: three years plus ten months. Because both dates fall on the 15th, no partial month is dropped.
Approach 2: years times twelve plus the leftover months
=DATEDIF(B2, C2, "y")*12 + DATEDIF(B2, C2, "ym")
"y" gives 2 whole years (24 months) and "ym" gives the 10 months on top; 34 is the same answer built from two units. Useful when you also want to print "2 years 10 months".
Function guide
FAQ
How do I calculate months between two dates in Excel?
=DATEDIF(start, end, "m"). It counts complete months, so 2026-01-15 to 2026-02-14 is 0, not 1.
Why is DATEDIF not in Excel's function list?
It is a Lotus 1-2-3 compatibility function: Excel supports it but does not offer autocomplete or help for it. Type the name in full and the formula still works.