Date and Time - DATEDIF Function



Description

The DATEDIF function calculates the number of days, months, or years between two dates. This function is provided for compatibility with Lotus 1-2-3.

Syntax

DATEDIF (start_date,end_date,unit)

Arguments

Argument Description Required/ Optional
Start_date

A date that represents the first, or starting, date of the period.

Dates may be entered as text strings within quotation marks (E.g. "2001/1/30"), as serial numbers (E.g. 36921, which represents January 30, 2001, if you are using the 1900 date system), or as the results of other formulas or functions (E.g. DATEVALUE ("2001/1/30")).

Required
End_date A date that represents the last, or ending, date of the period. Required
Unit

The type of information that you want returned.

Look at the Unit Table given below.

Required

Unit Table

Unit Returns
"Y" The number of complete years in the period.
"M" The number of complete months in the period.
"D" The number of days in the period.
"MD" The difference between the days in start_date and end_date. The months and years of the dates are ignored.
"YM" The difference between the months in start_date and end_date. The days and years of the dates are ignored
"YD" The difference between the days of start_date and end_date. The years of the dates are ignored.

Notes

  • Excel stores dates as sequential serial numbers so that they can be used in calculations. January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900

  • The DATEDIF function is useful in formulas where you need to calculate age.

Applicability

Excel 2007, Excel 2010, Excel 2013, Excel 2016

Example

DATEDIF Function
advanced_excel_date_time_functions.htm
Advertisements