EXCEL SOLUTIONS

DATEDIF function in Excel

Counts the complete years, months or days between two dates.

IntermediateDates

Syntax

=DATEDIF(start_date, end_date, unit)
Arguments of DATEDIF
ArgumentWhat it means
start_dateThe earlier date.
end_dateThe 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)

RowABCDE
1NameDepartmentSalaryStart dateRating
2Amira HassanFinance92002019-03-044
3Ben CarterSales78002021-07-193
4Chen WeiSales81002020-01-135
5Dina AliHR72002022-09-014
6Emil NovakOperations69002018-11-262
7Farah KhanFinance104002016-05-095
8Gabriel SilvaOperations65002023-02-143
Team list (fictional) Row 1 holds the headings. All data is fictional. Dates are year-month-day.

Download CSV

  • =DATEDIF(D2,DATE(2025,12,31),"Y")6

    Whole years of service for Amira at the end of 2025

  • =DATEDIF(D3,DATE(2025,12,31),"YM")5

    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.

    =DATEDIF(D6,DATE(2025,6,1),"Y")6
    Data: Team list (fictional)
  • Administration

    Months between two dates.

    =DATEDIF(DATE(2025,1,15),DATE(2025,6,14),"M")4

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

DATETODAYNETWORKDAYS

Lessons that use it

Tools that help

Need Something Different? Let’s Talk.

Looking for different features or something built around your workflow? Share your idea with us.