Home » Guides » Excel: How to use the DATEDIF function to calculate Difference Between two dates (2023)

How to use DATEDIF in Excel (2023)

To use DATEDIF function in Excel, this guide has some tips and tricks to follow.

The DATEDIF function is used to calculate the difference between two dates. This function returns the number of days, months, or years between two dates, depending on the unit value you specify. If you are new to Excel and don’t know how to use the DATEDIF function, look no further as this guide will teach you how to do it.

Excel: How to use the DATEDIF function (2023)

Excel: How to use the DATEDIF function

To use the DATEDIF function in Excel, you can type the following syntax in any cell:

=DATEDIF(start_date, end_date, unit)

Where the start_date and end_date are the dates you want to compare. They can be entered as text, serial numbers, or cell references. On the other hand, a unit is a value that determines how the difference is calculated (date, month, or year). Note that in the following syntax, you need to write the start and end dates inside the double quotes unless you are using the “TODAY()” function which is used to enter today’s date.

Unit Values

The unit values for the DATEDIF functions are as follows:

  • Type “Y” for years
  • Type “M” for months
  • Type “D” – for days
  • Type “MD” for days excluding months and years
  • Type “YM” for months excluding years and days
  • Type “YD” for days excluding years

For example, if you want to calculate how many months have passed since January 1st, 2001, you can use this formula:

=DATEDIF(“1/1/2001″, TODAY(),”M”)

This will return the number of complete months between January 1st, 2001, and today’s date. i.e. 279 months.

Syntax Errors

The DATEDIF function may return an error if:

  • The start date or end date values are not valid dates
  • The start date value is later than the end date value.
  • The unit value is not one of the valid values.

That’s everything covered on how to use the DATEDIF function in Excel. Also, check out our other guides, such as How to insert the drop-down list in Excel or How to delete the duplicate value in Excel.