Excel - DATEDIF Function



DATEDIF Function

The Excel DATEDIF function evaluates the differences between the start_date and the end_date in days, months, or years. The DATEDIF(Date +Dif) function is considered a compatible function originating from the Lotus 1-2-3. This function is not built into the Insert function dialog box, and you can directly employ it in the Excel formulas.

For example, The DATEDIF function might be used to calculate how long a employee has been employed from their Hire date until today, determine a student's age, calculate the duration of financial investments, measure the tenure of the specific contract and so forth.

Compatibility

This advanced Excel function is compatible with the following versions of MS-Excel

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016
  • Excel 2013
  • Excel 2010
  • Excel 2007

Syntax

The syntax of the DATEDIF formula is as follows −

=DATEDIF(start_date,end_date,unit)

Arguments

You can use the following arguments with the DATEDIF function −

Argument Description Required / Optional
Start_date It specifies the starting date of the specific date. You can use a date serial number or date function to enter dates or the result of the other formulas. Required
End_date It specifies the end date of the specific period. Required
Unit

The type of information that you want returned.

Look at the Unit Table given below.

Required

Unit Table

Unit Returns
"Y" It specifies the total number of years in the time frame.
"M" It specifies the total number of months in the time frame.
"D" It specifies the total number of days in the time frame.
"MD" It indicates the difference between the days in two defined dates mentioned in the first two arguments, "Start_date" and "End_date". The months and years are avoided.
"YM" It represents the difference between the months in two defined dates mentioned in the first two arguments, "Start_date" and "End_date". The days and years are avoided.
"YD" It indicates the difference between the days in two defined dates mentioned in the first two arguments, "Start_date" and "End_date". The years are avoided.

Points to Remember

  • This function is used to facilitate backward compatibility and must not be utilized.
  • If you directly enter the dates in the start_date and end_date then dates must be enclosed in double quotation marks. Otherwise, the DATEDIF function will not work.
  • If the start_date is greater than the end_date, then the DATEDIF function returns the #NUM! error.
  • If an invalid date is specified in the start_date argument, then the DATEDIF function will retrieve the #VALUE! error.
  • If an invalid date is specified in the end_date argument, then the DATEDIF function will retrieve the #VALUE! error.
  • If units are other than predefined units(YM, MD,Y,M, D, YD), then in this case, the DATEDIF function will retrieve the #NUM! error.
  • If you set the "unit" argument to "MD", then the year will extract from the "end_date".
  • If you set the "unit" argument to "YM", then the year will fetch from the "start_date".

Example

DATEDIF Function in Excel
Advertisements