How to Use DATEDIF Function in Excel[3 Examples]

In the vast world of Excel functions, the DATEIF function stands out as a powerful tool for handling date calculations efficiently. Whether you’re managing project timelines, tracking employee tenure, or calculating the duration between two events, DATEIF comes to the rescue. In this article, we’ll explore the ins and outs of the DATEIF function, its syntax, arguments, and output type, and provide real-world examples to demonstrate its versatility.

What Does the Excel DATEIF Function Do?

The DATEIF function, short for “Date Difference,” calculates the difference between two dates in terms of years, months, or days. It returns the count of full years, months, or days between the specified start and end dates, excluding partial periods. This makes it ideal for various date-related calculations, such as age determination, project duration, or tenure calculations.

What is the Syntax of the Excel DATEIF Function?

The syntax of the DATEIF function is relatively straightforward:

=DATEDIF(start_date, end_date, unit)

What Are the Arguments of the Excel DATEIF Function?

The DATEIF function requires three arguments:

  • start_date: The beginning date.
  • end_date: The ending date.
  • unit: The unit of measurement to determine the difference.

What is the Output Type of the Excel DATEIF Function?

The output type of the DATEIF function depends on the specified unit:

  • For “Y” (years), the output is the count of complete years between the two dates.
  • The output is the count of complete months between the two dates for “M” (months).
  • For “D” (days), the output is the count of complete days between the two dates.

3 Examples of Using the DATEIF Function in Excel

Let’s delve into practical examples to understand how the DATEIF function works:

Example 1: Calculating Age

Suppose we have a birth date in cell A2 and the current date in cell B2. To calculate the age in years, use the formula:

=DATEDIF(A2, B2, "Y")

Example 2: Tracking Project Duration

Assuming the project start date is in cell A3 and the end date is in cell B3. To determine the project duration in months, use:

=DATEDIF(A3, B3, "M")

Example 3: Employee Tenure Calculation

If the employee’s hire date is in cell A4 and the current date is in cell B4, you can find the tenure in days using:

=DATEDIF(A4, B4, "D")

Applying DATEDIF function to extract day, month and year in Excel

Things to Remember

  • The DATEIF function is not available in Excel’s formula autocomplete feature, but you can still use it by typing the formula manually.
  • Ensure that the start_date is earlier than the end_date, or else the function will return a “#NUM!” error.
  • Excel’s DATEIF function may give slightly different results in certain cases compared to other methods of calculating date differences.


The DATEIF function in Excel simplifies date calculations by providing a convenient way to determine the difference between two dates in terms of years, months, or days. By understanding its syntax, arguments, and output types, you can efficiently handle various date-related tasks, from age calculation to project tracking. Incorporate DATEIF into your Excel arsenal to streamline your date-based analyses and boost productivity.

Frequently Asked Questions

Can the DATEIF function handle leap years?

Yes, the DATEIF function can accurately calculate age, taking leap years into account. By specifying the unit as “Y” (years), it calculates the difference between two dates in complete years, accurately reflecting age.

Can I use DATEIF to calculate time differences?

No, the DATEIF function is designed specifically for date differences and does not handle time values.

Why isn’t the DATEIF function showing up in Excel’s function autocomplete feature?

The DATEIF function is one of the few Excel functions that do not appear in the function autocomplete feature. However, you can still use it by manually typing the formula. Simply enter “=DATEDIF(” in a cell, and Excel will prompt you with the function’s arguments.

Rate this post

Leave a Reply

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