Google Sheets DATEDIF Function: Syntax, Examples & Tips

The DATEDIF function calculates the difference between two dates in specified units (days, months, or years).
Google Sheets
DATEDIF(start_date, end_date, unit)

One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.

On this page
  1. Parameters
  2. What is DATEDIF?
  3. A Practical Example
  4. DATEDIF Formula
  5. Result of the Formula
  6. Why Use DATEDIF?
  7. Key Takeaways:
  8. Example use case

Parameters

start_date:
The starting date from which to begin the calculation. This can be a date value, a cell reference containing a date, or a formula that returns a date.

end_date:
The ending date up to which to calculate the difference. This can also be a date value, a cell reference containing a date, or a formula that returns a date.

unit:
The unit of time in which to express the difference between the two dates. This can be "Y" for years, "M" for months, "D" for days, "MD" for the difference in days ignoring months and years, "YM" for the difference in months ignoring years, or "YD" for the difference in days ignoring years.

What is DATEDIF?

The DATEDIF function in Google Sheets is a useful tool for calculating the difference between two dates. It allows you to find the difference in days, months, or years, making it an essential function for anyone who needs to analyze time intervals in their data. The function is particularly helpful for tracking age, project timelines, or any scenario where understanding the duration between two dates is crucial.

In simpler terms, DATEDIF helps you quantify the time that has passed between two specific dates in a straightforward manner.

A Practical Example

Imagine you are managing employee records and need to calculate their ages based on their birth dates:

Employee Table:

EmployeeIDNameBirthDate
1John Doe1990-05-15
2Jane Smith1985-08-22
3Bob Brown2000-01-30

You want to find out how old each employee is as of today.

DATEDIF Formula

To achieve this, you would use the DATEDIF function as follows:

Google Sheets
=DATEDIF(B2, TODAY(), "Y")

In this formula:

  • B2 is the cell containing the BirthDate of the employee.
  • TODAY() returns the current date.
  • "Y" specifies that you want the difference in complete years.

Result of the Formula

When you apply the DATEDIF formula to the Employee Table, the output would look like this:

EmployeeIDNameBirthDateAge
1John Doe1990-05-1533
2Jane Smith1985-08-2238
3Bob Brown2000-01-3023

In this case, the DATEDIF function calculates the age of each employee based on their birth date and the current date.

Why Use DATEDIF?

DATEDIF is beneficial because it simplifies the process of calculating date differences without the need for complex formulas. It provides a straightforward way to extract meaningful information from date data, making it easier to analyze time-related metrics. Additionally, it allows for flexibility in specifying the unit of measurement (days, months, or years), enhancing its usability.

Key Takeaways:

  • DATEDIF: A Google Sheets function that calculates the difference between two dates.
  • Flexible Units: Can return differences in days, months, or years, depending on your needs.
  • Simplicity: Provides an easy way to quantify time intervals without complex calculations.
  • Common Use Cases: Ideal for age calculations, project timelines, and any scenario where date differences are relevant.

DATEDIF is an essential function for anyone working with dates in Google Sheets, providing a powerful way to enhance data analysis and reporting capabilities.

Happy spreadsheeting!

Example use case

You have a table with employee start dates in Column A and today's date in Column B. Use DATEDIF to calculate the tenure of each employee in years. This helps HR track employee longevity and plan for anniversaries or retention strategies efficiently.

Need more help with Google Sheets formulas?

Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.

Explore all Google Sheets formulas

Browse our complete library of Google Sheets formula guides

Compare your options

Decide with evidence, not a sales pitch.

Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.

  1. 01ChatGPTOpen a balanced comparison prompt in ChatGPT.
  2. 02ClaudeOpen the same research prompt in Claude.
  3. 03PerplexityResearch the comparison with linked web sources.

AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.