How to Calculate Years, Months, and Days Between Two Dates in Excel
Question details
The user needs to calculate the exact duration in years, months, and days between a start date and an end date in Excel, such as determining a person's exact age.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating exact time elapsed, age, or project duration between two specific dates.
- Observed behavior
- The user wants to obtain a detailed breakdown of complete years, remaining months, and remaining days using Excel functions without manual counting.
Ensure your start date and end date are formatted as valid Excel dates (e.g., MM/DD/YYYY) so the formula can process them correctly.
Use the DATEDIF Function for Exact Date Differences
The DATEDIF function is the most accurate and efficient way to calculate the exact difference between two dates in years, months, and days.
The DATEDIF function calculates the difference between a start date and an end date. It takes three arguments: the start date, the end date, and the unit of time you want to measure (like "Y" for years, "YM" for months excluding years, and "MD" for days excluding months and years).
Enter your start date in cell A1 (e.g., 1/20/2023) and your end date in cell B1 (e.g., 2/21/2024).
Select a blank cell and enter the formula =DATEDIF(A1,B1,"Y"). This will return the number of full years.
In another cell, enter the formula =DATEDIF(A1,B1,"YM"). This calculates the number of remaining months after subtracting the complete years.
In a third cell, enter the formula =DATEDIF(A1,B1,"MD"). This returns the remaining days after subtracting the years and months.
To see the full result in one cell, use the formula: =DATEDIF(A1,B1,"Y") & " Years, " & DATEDIF(A1,B1,"YM") & " Months, " & DATEDIF(A1,B1,"MD") & " Days".

Try WPS Spreadsheet for Seamless Date Calculations
WPS Spreadsheet fully supports the DATEDIF function and offers a highly intuitive interface for all your data and time calculations. It is a powerful, free alternative to Microsoft Excel that makes formula processing simple and fast.
- 1. Open WPS Spreadsheet: Launch WPS Office and open a new or existing Spreadsheet document.
- 2. Input date values: Enter your start date and end date into two separate cells (e.g., A1 and B1).
- 3. Apply the DATEDIF formula: Type =DATEDIF(A1,B1,"Y") to calculate years, changing the last unit to "YM" or "MD" for months and days respectively, and press Enter.

Frequently Asked Questions
Why am I getting a #NUM! error when using the DATEDIF function?
The #NUM! error occurs if the start date is greater (more recent) than the end date. Ensure your earlier date is the first argument (A1) and the later date is the second argument (B1) in the formula.
Can I type the dates directly into the DATEDIF formula instead of using cell references?
Yes, you can enter dates directly into the formula, but they must be enclosed in quotation marks to be recognized as text strings. For example: =DATEDIF("1/20/2023","2/21/2024","Y").
Is the DATEDIF function available in all versions of Excel?
Yes, DATEDIF is supported in all modern versions of Excel and WPS Spreadsheet to ensure Lotus 1-2-3 compatibility. Because it is a legacy function, it won't show up in the formula wizard, but it functions correctly when typed manually.




