Note: The other languages of the website are Google-translated. Back to English

Excel Formula: Calculate Years Months Days between Two Dates

doc calculate difference between time 5

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.
doc calculate difference between time 5

Generic formula:

DATEDIF(start_date,end_date,"y")&" years "&DATEDIF(start_date, end_date,"ym")&" months " &DATEDIF(start_date, end_date,"md") &" days"

Arguments

Start_date, end_date: the starting date and ending date that you want to calculate the years, months and days between.

Error

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.
doc calculate difference between time 5

Then format the results as date format by clicking Home > Number Format drop-down menu > Short Date or Long Date.

Explanation

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.


Relative Formulas

Relative Functions


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Comments (5)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
The above formula shows page error
This comment was minimized by the moderator on the site
Not page error, but Parse Error
This comment was minimized by the moderator on the site
Hi, SUHAIL AHMAD NEHVI, could you upload the error picture? I have tested this formula times, it worked. I do not know what the specific problem you meet.
This comment was minimized by the moderator on the site
Grazie, MOLTO UTILE!
Rated 5 out of 5
This comment was minimized by the moderator on the site
MOLTE GRAZIE, UTILISSIMO!
There are no comments posted here yet

Follow Us

Copyright © 2009 - www.extendoffice.com. | All rights reserved. Powered by ExtendOffice. | Sitemap
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Protected by Sectigo SSL