Microsoft KB Archive/129277

{| = XL: Undocumented Worksheet Function DATEDIF =
 * width="100%"|

Last reviewed: February 2, 1998

Article ID: Q129277 The information in this article applies to:
 * Microsoft Excel 98 Macintosh Edition
 * Microsoft Excel 97 for Windows
 * Microsoft Excel for Windows 95, version 7.0
 * Microsoft Excel for Windows, versions 5.0, 5.0c
 * Microsoft Excel for the Macintosh, versions 5.0, 5.0a

SUMMARY
In Microsoft Excel, there is an undocumented worksheet function, DATEDIF, which calculates the difference between two dates in days, months, or years. The following information describes this function, its parameters, and how to obtain the same information using documented functions in Microsoft Excel.

For information about using documented functions instead of the DATEDIF function to calculate the difference between two dates, in days, months, or years, please see the following articles in the Microsoft Knowledge Base:

ARTICLE-ID: Q67093 TITLE    : How to Calculate the Number of Months Between Two Given Dates

ARTICLE-ID: Q27089 TITLE    : XL: Calculating the Number of Days Between Two Dates

ARTICLE-ID: Q81694 TITLE    : XL: Formula to Calculate Number of Days in Month

MORE INFORMATION
The DATEDIF function uses the following parameters:

DATEDIF(start_date,end_date,units_text) NOTES: start_date: The starting date of the period that you are calculating.

end_date: The ending date of the period that you are calculating.

(If you are calculating an age to today's date, you can use the TODAY function for the end_date argument.)

units_text: Specifies units to measure the difference in:

"Y"  returns the number of full years in the period "M"  returns the number of full months in the period "D"  returns the number of full days in the period "md" returns the number of full days in excess of the last full month "ym" returns the number of full months in excess of the last full year "yd" returns the number of full days in excess of the last full year In the following example A1: 11/11/69 A2: 04/05/95 A3: =DATEDIF(A1,A2,"Y") cell A3 returns the value 25 for 25 full years difference between the date in cell A1, and the date in cell A2. Note that the DATEDIF function is also available in Lotus 1-2-3.
 * }