Catalog

How to Calculate Years Between Two Dates in Excel A Comprehensive Guide

August 24, 2023 1.6K views

In our daily lives, Excel serves as a powerful tool for handling data, and sometimes, we need to determine the age of individuals based on their date of birth and the current date. However, calculating the years between two dates in Excel might seem daunting.

In this comprehensive guide, we will walk you through the process of using Excel functions to achieve this task effortlessly. Additionally, we'll introduce you to WPS Office, an excellent free alternative to traditional office suites.

Part 1. Basic Formulas for Date Calculations: YEARFRAC & DATEDIF

When it comes to date calculations in Excel, two fundamental functions stand out – YEARFRAC and DATEDIF. These powerful tools offer unique functionalities for handling dates and determining the time intervals between them. Let's explore each function in detail:

  1. YEARFRAC Function: The YEARFRAC function calculates the fraction of the year between two dates. It returns a decimal value representing the portion of the year that falls within the given date range.

Syntax: YEARFRAC(start_date, end_date, [basis]

YEARFRAC Function


  1. DATEDIF Function: The DATEDIF function calculates the difference between two dates in days, months, or years. It returns the count of days, months, or years between the specified dates, depending on the unit provided.

Syntax: DATEDIF(start_date, end_date, unit)

DATEDIF Function


Difference between the Functions:

Function

Purpose

Output

Example


YEARFRAC

Calculates year fraction between two dates

Decimal values representing the portion of the year

YEARFRAC("01/01/2020", "06/30/2021", 1) = 1.5




DATEDIF

Calculates the difference between two dates in days, months,or years

Count of days, months, or years depending on the unit provided

DATEDIF("01/01/2020", "06/30/2021", "d") = 546


DATEDIF("01/01/2020", "06/30/2021", "m") = 17


DATEDIF("01/01/2020", "06/30/2021", "y") =


Part 2. Calculating the Exact Years Between Two Dates

Knowing how to precisely calculate the years between two dates is a fundamental skill in Excel. In this part, we will focus on the DATEDIF function and guide you through a step-by-step tutorial. By the end of this section, you'll be equipped to effortlessly calculate the exact number of years between any two given dates using Excel.

#1. DATEDIF Function Tutorial:

Learn how to use the DATEDIF function in Excel to calculate the years between two dates accurately. This step-by-step tutorial will guide you through the process, making date calculations a breeze.

Step 1. Enter your two dates in separate cells.

Step 2. In a blank cell, type the formula: `=DATEDIF()`

DATEDIF Function

Step 3. Replace "start_date" and "end_date" with the cell references of your actual dates.

Step 4. Press Enter, and the result will be the number of years between the two dates.

#2. YEARFRAC Function Tutorial:

Discover the power of the YEARFRAC function in Excel, which allows you to calculate fractional years between dates. This straightforward tutorial will show you how to apply the function with ease.

Step 1. Enter your two dates in separate cells.

Step 2. In a blank cell, type the formula: `=YEARFRAC()`

YEARFRAC Function


Step 3. Replace "start_date" and "end_date" with the cell references of your actual dates.

Step 4. Press Enter, and the result will be the fractional number of years between the two dates.

Using these functions, you can easily calculate the years between two dates in Excel, simplifying date-related calculations.

Part 3. Handling Different Date Calculate: Month and Day

Aside from calculating years, Excel allows you to determine the months and days between two dates. In Part 3, we will continue our exploration of the DATEDIF function, demonstrating how it can be used to calculate both months and days. Follow along with our comprehensive tutorial, and you'll be proficient in handling various date calculations with ease.

Example Scenario: Let's say you have two dates in cells A2 and B2, and you want to calculate the number of months and days between these two dates.

Step 1: Open a New Excel Worksheet Open Microsoft Excel and create a new worksheet.

Step 2: Input Dates In cell A2, enter the start date, and in cell B2, enter the end date. For this example, use the date format "MM/DD/YYYY."

Input Dates


Step 3: Manually Enter the DATEDIF Function Since the DATEDIF function is not available in the function list, you need to manually type it into a cell to use it. Let's say you want to calculate the months between the two dates and display the result in cell C2.

In cell C2, type the following formula: =DATEDIF(A2, B2, "m")

Dateif Function


Step 4: Calculate the Days To calculate the remaining days after calculating the months, we'll use another formula in cell D2.

In cell D2, type the following formula:

=DATEDIF(A2, B2, "d")

Dateif result


Step 5: Format the Cells To display the results neatly, you can format cells C2 and D2 to make them more readable. Right-click on the cells, choose "Format Cells," and set the format to "Number" with no decimal places.

Fomat cells


Step 6: View the Results Now, you should see the number of months between the dates in cell C2 and the number of days in cell D2.

Part 4. A Free Alternative Choice——WPS Office

WPS Office logo


As we near the end of our guide, we introduce you to WPS Office, a free alternative that rivals traditional office suites. In this final part, discover the power and versatility of WPS Office as it offers seamless compatibility with different document formats. Learn why WPS Office is an excellent choice for your office needs, without the need for expensive subscriptions or software licenses.

Key Features of WPS Office:

  1. Free to Use: Enjoy the full functionality of WPS Office without any subscription fees.

  2. Strong Compatibility: Easily work with Microsoft Office file formats without any compatibility issues.

  3. Document Processing: Create professional documents with WPS Writer, a feature-rich word processing tool.

  4. Presentation Creation: Craft compelling presentations using WPS Presentation, complete with various templates and effects.

  5. Spreadsheet Management: Handle data and calculations effortlessly with WPS Spreadsheets.

  6. PDF Editing: Edit, annotate, and convert PDFs with ease using WPS PDF.

Experience the convenience and power of WPS Office, a fantastic alternative to expensive office software., To download WPS Office, visit the official website at https://www.wps.com/ . Look for the "Download" button or section on the website, and follow the instructions to download the software for your specific operating system.

Trustpilotstars4.8
WPS Office- Free All-in-One Office Suite
  • Use Word, Excel, and PPT for FREE, No Ads.

  • Edit PDF files with the powerful PDF toolkit.

  • Microsoft-like interface. Easy to learn. 100% Compatibility.

  • Boost your productivity with WPS's abundant free Word, Excel, PPT, and CV templates.

5,820,008 User
avator
Algirdas Jasaitis
logo

FAQs

1. How do you check if a date is before another date in Excel?

To check if a date is before another date in Excel, you can use a simple comparison formula:

Step 1. Assuming the date in cell A1 and the date in cell B1:

Step 2. In a new cell, enter the following formula: =A1 < B1

Step 3. Press Enter.

The cell will display either TRUE or FALSE based on the comparison result. If the date in cell A1 is before the date in cell B1, it will show TRUE; otherwise, it will show FALSE.

2.What is string date format?

A string date format is how a date is represented as a sequence of characters (letters, numbers, and symbols). It makes dates easily readable by both humans and computers.

3.Can we compare two strings directly?

Yes, in Excel, you can compare two strings directly using built-in functions. Excel provides several functions that allow you to compare strings and return a result based on the comparison.

Summary

This article is a comprehensive guide on date calculations in Microsoft Excel, covering fundamental formulas like YEARFRAC and DATEDIF, along with step-by-step tutorials on calculating exact years between two dates. It also explains how to handle different date calculations for months and days using DATEDIF. Additionally, the article recommends WPS Office as a free alternative to traditional office suites, emphasizing its strong compatibility with Microsoft Office and its cost-effectiveness, making it a compelling choice for users seeking a powerful office solution without any subscription fees.


15 years of office industry experience, tech lover and copywriter. Follow me for product reviews, comparisons, and recommendations for new apps and software.