Formula guide · Excel and Google Sheets · Updated May 13, 2026
DATEDIF Examples
Use DATEDIF to calculate years, months, or days between two dates.
Quick Answer
DATEDIF returns the difference between two dates using units like Y, M, D, YM, MD, or YD.
Copyable Formula
=DATEDIF(A2,B2,"Y")
Syntax
=DATEDIF(start_date, end_date, "unit")
Excel and Google Sheets
Worked Example
| A | B | C |
|---|---|---|
| Start | End | Years |
| 2021-04-15 | 2026-05-13 | 5 |
Result: Returns 5 complete years between the two dates.
Steps
- Put the earlier date first.
- Choose the unit that matches the question.
- Use separate formulas when you need years plus remaining months or days.
Common Mistakes
- Putting the end date before the start date.
- Using MD without checking month-end edge cases.
- Treating DATEDIF as a deadline calculator when WORKDAY may be better.
Excel vs Google Sheets Notes
The core idea works in both Excel and Google Sheets, but separators, function availability, and array behavior can vary by account, locale, and version.
Editorial check: This guide was last updated May 13, 2026. Formula behavior can vary by Excel version, Google Sheets rollout, and spreadsheet locale.