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)

Start_date     A date that represents the first, or starting, date of the period. Dates may be entered as text strings within quotation marks (for example, "2001/1/30"), as serial numbers (for example, 36921, which represents January 30, 2001, if you're using the 1900 date system), or as the results of other formulas or functions (for example, DATEVALUE("2001/1/30")).

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

Unit     The type of information that you want returned:

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.

Remarks

  • Dates are stored as sequential serial numbers so they can be used in calculations. By default, December 31, 1899 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900.
  • The DATEDIF function is useful in formulas where you need to calculate an age.

Examples

Start_date End_date Formula Description (Result)
1/1/2001 1/1/2003 =DATEDIF(Start_date,End_date,"Y") Two complete years in the period (2)
6/1/2001 8/15/2002 =DATEDIF(Start_date,End_date,"D") 440 days between June 1, 2001, and August 15, 2002 (440)
6/1/2001 8/15/2002 =DATEDIF(Start_date,End_date,"YD") 75 days between June 1 and August 15, ignoring the years of the dates (75)
6/1/2001 8/15/2002 =DATEDIF(Start_date,End_date,"MD") The difference between 1 and 15 — the day of start_date and the day of end_date — ignoring the months and the years of the dates (14)
 
 
Applies to:
SharePoint Server 2007, Windows SharePoint Services 3.0, Deployment Center 2003