The DATEDIF function is to count the number of days, months, or years between two dates.
Formula:
=DATEDIF(start_date,end_date,unit)
Explanations:
– The start_date is required, which is the first date that needs to count.
– The end_date is required, the second date needs to count.
– The unit is required, the data format you need to return. Please refer to the table below:
"Y" | The number of years |
"M" | The number of months |
"D" | The number of days |
"MD" | The difference when ignoring the years and months |
"YM" | The difference when ignoring the years and days |
"YD" | The difference when ignoring the year |
Cautions:
Dates are stored as sequential serial numbers and December 31, 1899 is serial number 1.
Example:
=DATEDIF(A2,B2,"Y")
The result returns 4. There are 4 years between the two dates.
=DATEDIF(A3,B3,"M")
The result returns 57. There are 57 months between the two dates.
=DATEDIF(A4,B4,"D")
The result returns 1761. There are 1761 days between the two dates.