Master the DATEDIF Function in Excel: Calculate Time Between Dates

Published: December 17, 2024 - 3 min read

Ashley Lenz

The DATEDIF function is Excel’s hidden powerhouse for calculating time intervals between dates. Whether you need to track employee tenure, calculate ages, or measure project durations, DATEDIF provides precise measurements in days, months, and years. This comprehensive guide will show you how to harness DATEDIF’s capabilities across all Excel versions.

How to Use the DATEDIF Function in Excel

The DATEDIF function requires three essential components: a start date, an end date, and a unit code that specifies your desired time measurement.

Basic Formula Structure

=DATEDIF(start_date, end_date, “unit”)

Let’s walk through a step-by-step example:

  1. Open your Excel spreadsheet
  2. Enter your start date in cell A2 (e.g., 1/1/2023)
  3. Enter your end date in cell B2 (e.g., 12/31/2023)
  4. In cell C2, enter the DATEDIF formula
  5. Select your desired unit code (see table below)

Unit Code

Measures

Example Formula

Result for 1/1/2023 to 12/31/2023

“Y”

Complete years

=DATEDIF(A2,B2,”Y”)

0

“M”

Total months

=DATEDIF(A2,B2,”M”)

11

“D”

Total days

=DATEDIF(A2,B2,”D”)

364

Calculate Age from Birth Date

DATEDIF excels at age calculations. Here’s how to implement various age-related formulas:

Basic Age Calculation

=DATEDIF(birthdate, TODAY(), “Y”)

Example using someone born on 5/15/1990:

=DATEDIF(“5/15/1990”, TODAY(), “Y”)

Precise Age with Months and Days

For a more detailed age calculation, combine multiple DATEDIF functions:

Component

Formula

Purpose

Years

=DATEDIF(A2,TODAY(),”Y”)

Full years

Months

=DATEDIF(A2,TODAY(),”YM”)

Remaining months

Days

=DATEDIF(A2,TODAY(),”MD”)

Remaining days

Coefficient Excel Google Sheets Connectors
Try the Free Spreadsheet Extension Over 500,000 Pros Are Raving About

Stop exporting data manually. Sync data from your business systems into Google Sheets or Excel with Coefficient and set it on a refresh schedule.

Get Started

Combined formula for displaying complete age:

=DATEDIF(A2,TODAY(),”Y”)&” years, “&DATEDIF(A2,TODAY(),”YM”)&” months, “&DATEDIF(A2,TODAY(),”MD”)&” days”

Track Project Durations

DATEDIF helps project managers track timelines effectively:

Project Duration Examples

Measurement

Formula

Use Case

Total Days

=DATEDIF(start_date,end_date,”D”)

Sprint duration

Complete Months

=DATEDIF(start_date,end_date,”M”)

Project phases

Years and Months

=DATEDIF(start_date,end_date,”Y”)&” years “&DATEDIF(start_date,end_date,”YM”)&” months”

Long-term projects

Advanced DATEDIF Applications

Employee Tenure Tracking

=DATEDIF(hire_date,TODAY(),”Y”)&” years “&DATEDIF(hire_date,TODAY(),”YM”)&” months”

Contract Duration

=DATEDIF(contract_start,contract_end,”D”)&” days”

Payment Terms Monitoring

=DATEDIF(invoice_date,payment_date,”D”)

Enhance Your Date Calculations with Coefficient

While DATEDIF is powerful for date calculations, modern businesses need real-time data integration for accurate reporting. Coefficient seamlessly connects your spreadsheets to live data sources, ensuring your date-based calculations always use the most current information.

Ready to take your spreadsheet capabilities beyond basic formulas? Get started with Coefficient to automate your data workflows and create real-time dashboards that keep your date-based analytics current and accurate.

Sync Live Data into Your Spreadsheet

Connect Google Sheets or Excel to your business systems, import your data, and set it on a refresh schedule.

Try the Spreadsheet Automation Tool Over 500,000 Professionals are Raving About

Tired of spending endless hours manually pushing and pulling data into Google Sheets? Say goodbye to repetitive tasks and hello to efficiency with Coefficient, the leading spreadsheet automation tool trusted by over 350,000 professionals worldwide.

Sync data from your CRM, database, ads platforms, and more into Google Sheets in just a few clicks. Set it on a refresh schedule. And, use AI to write formulas and SQL, or build charts and pivots.

Ashley Lenz Product Researcher @ Coefficient
As a product researcher at Coefficient, Ashley taps into the power of data to create intuitive solutions that save users valuable time. By working closely with users, Ashley helps to uncover key insights that shape product features, enabling teams to streamline workflows and boost productivity. Her passion for data-driven research and optimizing user experiences fuels her work, ensuring the product delivers maximum efficiency and value.
500,000+ happy users
Wait, there's more!
Connect any system to Google Sheets in just seconds.
Get Started Free

Trusted By Over 50,000 Companies