Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • How To Filter Data in Excel
  • How to Create Area Chart in Excel
  • Conditional Formatting Rules in Excel
  • How to calculate average last N values in a table in Excel
  • Understanding Pivot Tables in Excel

References

  • Excel Advanced Lookup using Index and Match Functions
  • Multi-criteria lookup and transpose in Excel
  • How to create dynamic named range with OFFSET in Excel
  • How to reference named range different sheet in Excel
  • How to use Excel COLUMN Function

Data Validations

  • Excel Data validation unique values only
  • Excel Data validation number multiple 100
  • Excel Data validation must begin with
  • Excel Data validation exists in list
  • Excel Data validation date in next 30 days

Get days, months, and years between dates in Excel

by

This tutorial show how to Get days, months, and years between dates in Excel using the example below.

To calculate and display the time between dates in days, months, and years, you can use the a formula based on the DATEDIF function.

Note: The DATEDIF function is designed to calculate the difference between dates in years, months, and days. There are several variations available (e.g. time in months, time in months ignoring days and years, etc.) and these are set by the “unit” argument in the function. See this page on the DATEDIF function for a full list of available units.

Worked Example:   Get days between dates ignoring years in Excel

Formula

=DATEDIF(start,end,"y") &" years,"&DATEDIF(start,end,"ym") &" months," &DATEDIF(start,end,"md") &" days"

Explanation of how this formula works

In the example shown, the formula in D6 is:

=DATEDIF(B6,C6,"y") &" years,"&DATEDIF(B6,C6,"ym") &" months," &DATEDIF(B6,C6,"md") &" days"

where start dates are in column B, and end dates are in column C.

Worked Example:   How to calculate next anniversary date or birthday in Excel

Using DATEDIF function;

In the example shown, we calculate years, months, and days separately, then “glue” the results together with concatenation. To get whole years, we use:

DATEDIF(B6,C6,"y")&" years,"

To get whole months, we use:

DATEDIF(B6,C6,"ym")&" months,"

And we calculate days with:

DATEDIF(B6,C6,"md")&" days"

The rest of the formula is simply the required text joined together with the concatenation operator (&).

Without zero values

To prevent the output of days, months, or years with zero values, you can wrap each DATEDIF function inside IF, as shown here (line breaks added for readability):

=
IF(DATEDIF(B6,C6,"y"), DATEDIF(B6,C6,"y")&"yr ","")&
IF(DATEDIF(B6,C6,"ym"), DATEDIF(B6,C6,"ym")&" mo ","")&
IF(DATEDIF(B6,C6,"md"), DATEDIF(B6,C6,"md") &" dy","")

To prevent extra commas from appearing in the final result, commas have been replaces by spaces. Using the original DATEDIF formula as the “logical test” inside IF works because IF treats any non-zero result as true.

Post navigation

Previous Post:

Number and Text Filters Examples in Excel

Next Post:

Convert date string to date time in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • IF, AND, OR and NOT Functions Examples in Excel
  • SWITCH function example in Excel
  • IF with wildcards in Excel
  • IF function: Description, Usage, Syntax, Examples and Explanation
  • Check multiple cells are equal in Excel

Date Time

  • How to calculate percent of year complete in Excel
  • Excel Date & Time Functions Example
  • TIME function: Description, Usage, Syntax, Examples and Explanation
  • Two ways to sum time over 30 minutes in Excel
  • How to get Weekdays, Working days between Two Dates in Excel

Grouping

  • Group times into unequal buckets in Excel
  • Group numbers with VLOOKUP in Excel
  • Calculate conditional mode with criteria in Excel
  • Group arbitrary text values in Excel
  • How to randomly assign data to groups in Excel

General

  • Spell Check in Excel
  • Delete Blank Rows at Once in Excel
  • Select, Insert, Rename, Move, Delete Worksheets in Excel
  • Convert column letter to number in Excel
  • Share Excel data with Word documents
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning