Returns the number of years, months, or days between two dates.
Syntax
Syntax: DATEDIF( DateParam StartDate ; DateParamEndDate ; Text Format )
Returns: Number
Constraints: None
Semantics: Compute difference between StartDate and EndDate, in the units given by Format.
The Format is a code from the following table, entered as text, that specifies the format you want the result of DATEDIF to have.
format | Returns the number of |
---|---|
y | Years |
m | Months. If there is not a complete month between the dates, 0 will be returned. |
d | Days |
md | Days, ignoring months and years |
ym | Months, ignoring years |
yd | Days, ignoring years |
Example
Syntax | Result |
---|---|
=DateDif("2005-01-01"; "2007-05-31"; "y") | 2 |
=DateDif("2005-01-01"; "2007-05-31"; "m") | 28 |
=DateDif("2005-01-01"; "2007-05-31"; "d") | 880 |
=DateDif("2005-01-01"; "2007-05-31"; "md") | 30 |
=DateDif("2005-01-01"; "2007-05-31"; "ym") | 4 |
=DateDif("2005-01-01"; "2007-05-31"; "yd") | 150 |