logo
search
Function Problems

How to Calculate Years, Months, and Days Between Two Dates in Excel

Maira MehtabMaira Mehtab Sep 25, 2026 870 views

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.

How to Calculate Years, Months, and Days Between Two Dates in Excel
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.
Before you start

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.

Solution 1Recommended

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).

1
Enter your dates

Enter your start date in cell A1 (e.g., 1/20/2023) and your end date in cell B1 (e.g., 2/21/2024).

2
Calculate complete years

Select a blank cell and enter the formula =DATEDIF(A1,B1,"Y"). This will return the number of full years.

3
Calculate remaining months

In another cell, enter the formula =DATEDIF(A1,B1,"YM"). This calculates the number of remaining months after subtracting the complete years.

4
Calculate remaining days

In a third cell, enter the formula =DATEDIF(A1,B1,"MD"). This returns the remaining days after subtracting the years and months.

5
Combine into a single string (Optional)

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".

Use the DATEDIF Function for Exact Date Differences
Hidden Function in Excel: DATEDIF is a "hidden" function in Excel, meaning it will not appear in the formula auto-complete dropdown menu. However, it will work perfectly when you type it manually.
Calculate Dates Easily

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. 1. Open WPS Spreadsheet: Launch WPS Office and open a new or existing Spreadsheet document.
  2. 2. Input date values: Enter your start date and end date into two separate cells (e.g., A1 and B1).
  3. 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.
Fully compatible with Microsoft Excel formulas, including DATEDIFFree, lightweight, and fast-loadingFamiliar user interface with zero learning curve for Excel usersBuilt-in templates for project management and timeline tracking
microsoft office alternative - wps office

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.