Syntax
=DATEDIF(start_date, end_date, unit)
| Argument | What it means |
|---|---|
start_date | The earlier date. |
end_date | The later date. |
unit | "Y" for years, "M" for months, "D" for days, "YM" for months left after the years, "MD" for days left after the months. |
Examples with results
Every result below is calculated by the practice engine on the sample data shown, not typed in by hand.
Team list (fictional)
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Name | Department | Salary | Start date | Rating |
| 2 | Amira Hassan | Finance | 9200 | 2019-03-04 | 4 |
| 3 | Ben Carter | Sales | 7800 | 2021-07-19 | 3 |
| 4 | Chen Wei | Sales | 8100 | 2020-01-13 | 5 |
| 5 | Dina Ali | HR | 7200 | 2022-09-01 | 4 |
| 6 | Emil Novak | Operations | 6900 | 2018-11-26 | 2 |
| 7 | Farah Khan | Finance | 10400 | 2016-05-09 | 5 |
| 8 | Gabriel Silva | Operations | 6500 | 2023-02-14 | 3 |
=DATEDIF(D2,DATE(2025,12,31),"Y")Whole years of service for Amira at the end of 2025
=DATEDIF(D3,DATE(2025,12,31),"YM")Months left over after the whole years for Ben
Try it yourself
Change the formula or switch to other sample data.
Press Calculate to see the result.
The practice box runs in your browser with BDK’s own calculator, which covers about 60 common functions. Cell references work as in Excel (B2, B2:B9). Your formulas are not saved or sent anywhere. For anything unusual, check the result in Excel itself.
How people use DATEDIF at work
- HR
Length of service in complete years.
Data: Team list (fictional)=DATEDIF(D6,DATE(2025,6,1),"Y") - Administration
Months between two dates.
=DATEDIF(DATE(2025,1,15),DATE(2025,6,14),"M")
Common mistakes and tips
- The start date must be before the end date or you get #NUM!.
- DATEDIF is an older function that Excel does not list in its formula helper, but it works. Type it by hand.
Works in
All versions of Excel, and Google Sheets.
Related formulas
Need Something Different? Let’s Talk.
Looking for different features or something built around your workflow? Share your idea with us.