The datedif function can be used in Microsoft Excel to calculate the number of days between 2 different dates.
The syntax for the DATEDIF
function is as follows:
=DATEDIF(Date1, Date2, Interval)
Where:
Date1
is the first date,
Date2
is the second date,
Interval
is the interval type to return.
If Date1
is later than
Date2
, DATEDIF
will return a #NUM!
error. If either
Date1
or Date2
is not a valid date, DATEDIF
will return a
#VALUE
error.
The Interval
value should be one of
the following:
Interval | Meaning | Description |
m |
Months | Complete calendar months between the dates. |
d |
Days | Number of days between the dates. |
y |
Years | Complete calendar years between the dates. |
ym | Months Excluding Years | Complete calendar months between the dates as if they were of the same year. |
yd |
Days Excluding Years | Complete calendar days between the dates as if they were of the same year. |
md |
Days Excluding Years And Months | Complete calendar days between the dates as if they were of the same month and same year. |
If Interval
is not one of the items listed in
above, DATEDIF
will return a
#NUM
error.