Excel Formula: Calculate Years Months Days between Two Dates
In Excel, you usually calculate the difference between two dates and display the results as days, or months or years. Here this tutorial introduces a formula that displays the difference between two dates as A years B months C days, such as 3 years 2 months 1 days.
If you want to follow along with this tutorial, please download the example spreadsheet.
|DATEDIF(start_date,end_date,"y")&" years "&DATEDIF(start_date, end_date,"ym")&" months " &DATEDIF(start_date, end_date,"md") &" days"|
|Start_date, end_date: the starting date and ending date that you want to calculate the years, months and days between.|
If the argument end_date is smaller than start_date, the formula returns an error value #NUM!.
How this formula work
To calculate the difference between two dates in cell B3 and C3 and show the result as years months and days, please use below formula:
|=DATEDIF(B3,C3,"y")&" years "&DATEDIF(B3, C3,"ym")&" months " &DATEDIF(B3, C3,"md") &" days"|
Press Enter key.
Then format the results as date format by clicking Home > Number Format drop-down menu > Short Date or Long Date.
DATEDIF function: This function returns the number of years, months, or days between two given dates.
DATEDIF(B3,C3,"y") returns the number of years between two dates.
DATEDIF(B3, C3,"ym") returns the number of months ignoring years and days between two dates.
DATEDIF(B3, C3,"md") returns the number of days ignoring years and months between two dates.
& is a connector that connects the results of each parts in the formula together.
- Calculate Difference Between Two Dates
Here in this tutorial, it introduces the formulas on calculating difference between two dates in years, months, weeks, and days.
- Calculate Calculate Days Hours Minutes Seconds Between Two Dates
Sometimes, we may want to get the days, hours, minutes, and seconds between two datetimes, this tutorial introduces the formula to solve this job.
- Calculate Days Remaining Between Two Dates
Here, this tutorial provides a formula to quickly calculate the left days between two dates.
- Calculate Hours Minutes Seconds Between Two Times
Here in this tutorial, it introduces some formulas to quickly present the time difference result as single time unit.
- Excel IF Function
Test for specified conditions, then returns the corresponding values
- Excel VALUE Function
Convert text to number.
- Excel MONTH Function
The MONTH is used to get the month as integer number (1 to 12) from date.
- Excel DAY Function
DAY function gets the day as a number (1 to 31) from a date
- Excel YEAR Function
The YEAR function returns the year based on the given date in a 4-digit serial number format.