Returns the number of days, months, or years between two given dates.
Syntax
DATEDIF(start_date; end_date; type)
start_date: Starting date for the period. E.g. "1/1/2020"
end_date: Final or end date for the specified period. E.g. "2/4/2018"
|
Type |
Returns |
|
Y |
Number of years in the given period |
|
M |
Number of months in the given period |
|
D |
Number of days in the given period |
|
MD |
Difference between days in start_date and end_date, ignoring the months and years. |
|
YM |
Difference between months in start_date and end_date, ignoring the days and years. |
|
YD |
Difference between the days in start_date and end_date, ignoring the years alone. |
Examples
|
Formula |
Result |
|
=DATEDIF("1/1/2018";"2/4/2020";"Y") |
2 |
|
=DATEDIF("4/13/2020";"11/1/2020";"D") |
202 |
|
=DATEDIF("4/13/2020";"11/1/2020";"MD") |
19 |
Possible Errors
|
Errors |
Meaning |
|
#N/A! |
|
|
#NAME! |
|
|
#VALUE! |
|
|
#REF! |
|
Similar Functions