Excel function DATEDIF

Excel function DATEDIF Calculates the number of days, months or years between two dates.

Warning: The DATEDIF function may calculate erroneous results in certain scenarios. Read the section on known issues in this article for more details.

Syntax Excel function DATEDIF

DATEDIF (start_date, end_date, unit) Start_date

A date that represents the date of the first or initial period. You can enter dates as text strings in quotation marks (for example, “2001/1/30”), as ordinal numbers (for example, 36921, which is January 30, 2001 if you use the 1900 date system), or as the result of other formulas or functions. (for example DATEVALUE (“2001/1/30”)).

End_Date The date that represents the date of the last or final period.

Unit Type of information you want to return:

Unit Gives
“Y” Number of whole years in the period.
“M” Number of whole months in the period.
“D” Number of days in the period.
MD

Difference between start date and end date. The months and years of the date are ignored.

IMPORTANT: We do not recommend using the “MD” argument, as there are known limitations to it. Read the section with known issues below.

“YM” Difference between months within start_date and end_date. Days and years of the date are ignored
“YD” Difference between start date and end date. Date years are ignored.
Remarks
Dates are stored as sequential ordinal numbers so that they can be used in calculations. It is understood that December 31, 1899 is ordinal number 1, and January 1, 2008 is ordinal number 39448 because it comes 39,448 days after January 1, 1900.
The DATEDIF function is useful in formulas that need to calculate age.

Known issues

The “MD” argument can give a result that is a negative number, zero or incorrect. Here’s a workaround if you’re trying to calculate the remaining days after the last month:

This formula subtracts the first day of the month ending (May 1, 2016) from the original end date in cell E17 (May 6, 2016). Here’s how it works: The first DATE function makes a date, 1.5.2016. Make it using the year in cell E17 and the month in cell E17. Then 1 represents the first day of that month. The result of the DATE function is May 1, 2016. Then we subtract that from the original completion date in cell E17, which is May 6, 2016. 5/6/2016 minus 5/1/2016 is 5 days.

Rate this post