Complete years
| A | B | |
|---|---|---|
| 1 | Start | End |
| 2 | 1/15/2020 | 3/20/2024 |
Formula: D2: =DATEDIF(A2,B2,"y")
Result: 4
From Jan 15, 2020 to Mar 20, 2024 is four complete years.
Difference between dates in "y", "m" or "d" (undocumented, but works).
DATEDIF(start_date, end_date, unit)Example: =DATEDIF(B2,TODAY(),"y")
Available in: All versions
DATEDIF returns the number of complete years, months or days between two dates: =DATEDIF(start, end, unit), with units "y", "m", "d", "ym", "md" and "yd". It is a long-standing function that does not appear in the formula autocomplete, but it works.
| A | B | |
|---|---|---|
| 1 | Start | End |
| 2 | 1/15/2020 | 3/20/2024 |
Formula: D2: =DATEDIF(A2,B2,"y")
Result: 4
From Jan 15, 2020 to Mar 20, 2024 is four complete years.
| A | B | |
|---|---|---|
| 1 | Start | End |
| 2 | 1/15/2020 | 3/20/2024 |
Formula: D2: =DATEDIF(A2,B2,"ym")
Result: 2
"ym" ignores years and counts the whole months after the last anniversary.
| A | B | |
|---|---|---|
| 1 | Start | End |
| 2 | 1/15/2020 | 3/20/2024 |
Formula: D2: =DATEDIF(A2,B2,"y")&" years, "&DATEDIF(A2,B2,"ym")&" months"
Result: 4 years, 2 months
Joins two DATEDIFs into one label.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =DATEDIF(A2,B2,"m")
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Start | End | Holiday | Time | Result | |
| 2 | 3/15/2026 | 6/20/2026 | 5/1/2026 | 14:45 | 3 | |
| 3 | 1/31/2026 | 2/28/2026 | 5/9/2026 | 09:30 | ||
| 4 | 12/24/2025 | 1/9/2026 |
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page