Skip to content
xlsoffice. All Rights Reserved
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Lookup and Reference Examples

  • Count rows that contain specific values in Excel
  • How to use Excel LOOKUP Function
  • Merge tables with VLOOKUP in Excel
  • How to get relative column numbers in a range in Excel
  • Complete List of Excel Lookup and Reference Functions, References and Examples

Data Analysis Examples

  • How to create a Histogram in Excel
  • Error Bars in Excel
  • How To Load Analysis ToolPak in Excel
  • How to calculate correlation coefficient Correlation in Excel
  • How to Use Solver Tool in Excel

Data Validation Examples

  • Excel Data validation must begin with
  • Excel Data validation allow weekday only
  • Excel Data validation unique values only
  • Excel Data validation require unique number
  • Excel Data validation specific characters only

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:   How to calculate number of Days until Birthday

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

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

Post navigation

Previous Post:

Steps to create Dynamic calendar grid in Excel

Next Post:

Get age from birthday 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
  • PHONETIC function: Description, Usage, Syntax, Examples and Explanation
  • Remove text by position in a cell in Excel
  • Two ways to Compare Text in Excel
  • How to abbreviate names or words in Excel
  • Convert text to numbers using VALUE function in Excel
  • YEAR function: Description, Usage, Syntax, Examples and Explanation
  • Add workdays to date custom weekends in Excel
  • Calculate time difference in hours as decimal value in Excel
  • Get age from birthday in Excel
  • How to calculate nth day of year in Excel
  • YIELDDISC function: Description, Usage, Syntax, Examples and Explanation
  • Calculate loan interest in given year in Excel
  • AMORLINC function: Description, Usage, Syntax, Examples and Explanation
  • XNPV function: Description, Usage, Syntax, Examples and Explanation
  • SLN function: Description, Usage, Syntax, Examples and Explanation
Acronyms, Abbreviations, Initialism & What They Stand For
© 2021 xlsoffice. All Rights Reserved | Teal Smiles