Microsoft Excel

How to Use DATEDIF in Excel (Analyze Dates Like a Boss!)

One of the most common questions I’m asked whenever I do Microsoft Excel training involves performing calculations with dates.

Participants often want to calculate the amount of time that has elapsed between a two dates. That’s when I tell them about DATEDIF!

The DATEDIF function in Excel is used to calculate the difference between two dates. DATEDIF calculates the duration between a start date and end date then returns the difference in days, months, or years.

DATEDIF is provided with Excel to maintain compatibility with Lotus 1-2-3 spreadsheets. Unlike most of Excel’s other functions, it won’t prompt you to enter the necessary arguments – but the syntax is fairly simple.

DATEDIF Function Syntax

The DATEDIF function accepts three arguments – all are required.


start_date can refer to a date displayed in a cell, it can be a string in quotes (“1/1/2022”), or it can be the output from other Excel functions.

end_date represents the last date in a period.

unit indicates whether you want DATEDIF to calculate the difference in days, months, or years. The unit argument isn’t case sensitive but should be enclosed in quotes.

Available units are described below.

“Y”Difference in complete years
“M”Difference in complete months
“D”Difference in days
“MD”Difference in days, ignoring months and years
“YM”Difference in months, ignoring years
“YD”Difference in days, ignoring years

Excel DATEDIF Function Examples

Let’s look at various ways you can use the Excel DATEDIF function to calculate the difference between two dates.

DATEDIF function examples
  • In Example #1, we use the DATEDIF function to calculate the difference between two dates. Cell E2 the number of days as 911.
  • Example #2 indicates that there were 29 complete months between the same two dates. Notice that our DATEDIF formula only returned the number of complete months.
  • Example #3 shows two complete years.
  • With MD specified as the unit in Example #4, the DATEDIF function returns a difference of 29 days, ignoring months and years.
  • Example #5 specifies YM as the unit and the Excel DATEDIF function returns the difference as 5 months, ignoring days and years.

Final Thoughts on the DATEDIF Function in Excel

The Excel DATEDIF function is a simple and convenient way to calculate the number of days, months, or years, between two dates.

You can use the DATEDIF function when you want to calculate:

  • Someone’s age
  • The duration of a project
  • Length of employment

Any time you have a start date and end date, the DATEDIF function in Excel returns the difference in days, months, or years.

By Michael Belfry

Working as a full-time training consultant, Michael provides Microsoft Office courses to government and private sector clients across Canada.