<< Click to Display Table of Contents >> DATEDIF (date difference) |
Syntax:
DATEDIF(StartDate, EndDate, Mode)
Description:
This returns the number of days, months or years between two dates.
StartDate and EndDate are the two dates to be evaluated. StartDate must be less (i.e., earlier) than EndDate.
Mode determines how and in which unit the difference between the StartDate and the EndDate should be calculated:
"y" |
Number of years between StartDate and EndDate |
"m" |
Number of months between StartDate and EndDate |
"d" |
Number of days between StartDate and EndDate |
"ym" |
Number of months, excluding years (as if StartDate and EndDate were in the same year) |
"yd" |
Number of days, excluding years (as if StartDate and EndDate were in the same year) |
"md" |
Number of days, excluding month and years (as if StartDate and EndDate were in the same month and year) |
Note:
This function is an undocumented Excel function. Although it still exists in Microsoft Excel, it has been removed from Excel's help file and thus seems to be no longer officially supported.
Example:
To calculate the age of a person, enter their date of birth in cell A1 (e.g., 4/3/1970). In A2, enter the current date (e.g., 6/8/2012).
Calculate the person's age as follows:
Age in years:
DATEDIF(A1, A2, "y") returns 42 (years)
Age in months:
DATEDIF(A1, A2, "m") returns 506 (months)
Age in days:
DATEDIF(A1, A2, "d") returns 15407 (days)
Age in years, months and days:
DATEDIF(A1, A2, "y") returns 42 (years)
DATEDIF(A1, A2, "ym") returns 2 (months)
DATEDIF(A1, A2, "md") returns 5 (days)
(The person's age is thus 42 years, 2 months and 5 days.)
See also: