Excel and Google Sheets DATEDIF Calculator
Generate formulas for complete days, months, or years.
How the Excel and Google Sheets DATEDIF Calculator Works
The Excel and Google Sheets DATEDIF Calculator writes a =DATEDIF(start_date, end_date, unit) formula and shows the result for each of the 6 units: Y, M, D, MD, YM and YD.
Enter the start date
Enter the earlier date. DATEDIF returns an error, if the start date is later.
Enter the end date
Enter the later date.
Pick the unit
Choose "Y" for years, "M" for months, "D" for days, or a combined unit.
Copy the formula
Paste the DATEDIF formula into a cell next to your dates.
How the Count Is Calculated
The DATEDIF function returns complete units between 2 dates.
=DATEDIF(start_date, end_date, unit)
Age as text: =DATEDIF(A1,B1,"Y")&" y "&DATEDIF(A1,B1,"YM")&" m "&DATEDIF(A1,B1,"MD")&" d"- "Y", "M", "D"
- Complete years, complete months, or days.
- "YM"
- Months left after complete years.
- "MD"
- Days left after complete months. Microsoft warns that "MD" can return wrong results in some cases.
- "YD"
- Days between the dates as if both were in the same year.
Example: Start = 17 May 2023, end = 4 December 2026. DATEDIF returns 3 for "Y", 6 for "YM" and 17 for "MD", which reads as 3 years, 6 months and 17 days.
Worked Examples
The table lists every DATEDIF unit for 17 May 2023 to 4 December 2026.
| Unit | Formula | Result |
|---|---|---|
| Y | =DATEDIF(A1,B1,"Y") | 3 |
| M | =DATEDIF(A1,B1,"M") | 42 |
| D | =DATEDIF(A1,B1,"D") | 1,297 |
| YM | =DATEDIF(A1,B1,"YM") | 6 |
| MD | =DATEDIF(A1,B1,"MD") | 17 |
| YD | =DATEDIF(A1,B1,"YD") | 201 |
What the Tool Measures
The DATEDIF function is a hidden Excel function that returns complete years, months or days between 2 dates. Excel keeps DATEDIF for Lotus 1-2-3 compatibility and leaves DATEDIF out of the formula autocomplete list.
Google Sheets lists and documents DATEDIF. Both apps return a #NUM! error, if the start date is later than the end date.
When to Use This Tool
There are 4 main uses of the Excel and Google Sheets DATEDIF Calculator, including age and tenure.
Age in years
HR sheets compute age with =DATEDIF(birth_date, TODAY(), "Y").
Tenure
Employee lists show years and months of service.
Loan age
Lenders compute months since a loan started.
Anniversary tracking
Sheets find days to the next anniversary with "YD".