Get days, months, or years between two dates
=DATEDIF(start_date, end_date, unit)
| Parameter | Description |
|---|---|
start_date |
Start date in Excel date serial number format. |
end_date |
End date in Excel date serial number format. |
unit |
The time unit to use (years, months, or days). |
=DATEDIF("1-Jan-2023","1-Mar-2025","y") // returns 2 (complete years)
=DATEDIF("1-Jan-2023","1-Mar-2025","m") // returns 26 (complete months)
=DATEDIF("1-Jan-2023","1-Mar-2025","d") // returns 790 (total days)
=DATEDIF("1-Jan-2023","1-Mar-2025","ym") // returns 2 (months after years)
=DATEDIF("1-Jan-2023","1-Mar-2025","yd") // returns 59 (days after years)
=DATEDIF("1-Jan-2023","1-Mar-2025","md") // returns 0 (days after months)
DATEDIF can calculate the difference between dates in days in three ways, using the "d", "yd", and "md" units. In the worksheet below, the goal is to
=DATEDIF(B5,C5,"d") // total days
=DATEDIF(B5,C5,"yd") // days ignoring years
=DATEDIF(B5,C5,"md") // days ignoring months and years
DATEDIF can calculate the difference between dates in months in two ways, using the "m" and "ym" units. In the worksheet below, the goal is to calcula
=DATEDIF(B5,C5,"m") // complete months
=DATEDIF(B5,C5,"ym") // months ignoring years
DATEDIF calculates the difference between dates in complete years with the "y" unit. In the worksheet below, the goal is to calculate the number of co
=DATEDIF(B5,C5,"y") // complete years
DATEDIF's ability to return different time components makes it ideal for expressing elapsed time as a combination of years, months, and days. In the w
=DATEDIF(B5,C5,"y") // years
=DATEDIF(B5,C5,"ym") // months
=DATEDIF(B5,C5,"md") // days
Together, the three results add up to the total time elapsed between the start date and end date. To display time elapsed as a single result like "X y
=DATEDIF(B5,C5,"y")&" years, "&DATEDIF(B5,C5,"ym")&" months, "&DATEDIF(B5,C5,"md")&" days"