உள்ளடக்கத்திற்கு செல்க
Date & TimeIntermediate LevelIntermediate Excel (Lookups & Business Analytics)

How to Use DATEDIF in Excel

Returns the difference between two dates in complete years, months or days — the standard way to calculate age and tenure.

Direct Answer (Quick Summary)

What is DATEDIF in Microsoft Excel?

DATEDIF measures the gap between two dates in a unit you choose: "Y" for whole years, "M" for whole months, "D" for days. It is a legacy function that Excel keeps hidden from the function list but still supports, and it remains the cleanest way to compute employee tenure and customer age.

Pro Tip: DATEDIF returns #NUM! when the start date is later than the end date. Guard it with IF: =IF(B2>C2,0,DATEDIF(B2,C2,"Y")).

Formula Syntax

=DATEDIF(start_date, end_date, unit)

Arguments Breakdown

ArgumentRequirementPurpose & Details
start_dateRequiredThe earlier date. Must be on or before end_date.
end_dateRequiredThe later date, often TODAY().
unitRequired"Y" whole years, "M" whole months, "D" days, "YM" leftover months, "MD" leftover days, "YD" leftover days ignoring years.

When to Use DATEDIF (Real-World Business Scenarios)

  • 1

    Calculating exact age in years from a date of birth with unit "Y".

  • 2

    Working out completed months of service for a probation or notice period.

  • 3

    Building tenure buckets for an HR dashboard without nesting YEAR and MONTH.

Step-by-Step Practical Business Example

Suppose you have the following dataset in Excel cells A1:D4:

EmployeeJoining DateTenure (Years)
Rahul2019-06-157
Pooja2022-01-104
Aman2025-03-011
Applied Formula:Result: 7
=DATEDIF(B2,TODAY(),"Y")

How it works: Counts only completed years between the joining date and today. A person who joined in June 2019 has 7 full years of service in November 2026.

Common Errors & How to Fix Them

#NUM!

Why it happens: The start date is later than the end date, which DATEDIF cannot express.

Fix: Swap the arguments or guard with IF(B2>C2,0,DATEDIF(B2,C2,"Y")).

Function missing from autocomplete

Why it happens: DATEDIF is a compatibility function and does not appear in the function wizard.

Fix: Type it manually — it still works in every Excel version and in Google Sheets.

Interactive Formula Lab

Try DATEDIF Live in Your Browser

No need to launch desktop Excel. Practice formulas with real-time feedback in our HyperFormula sandbox.

Open Practice Lab

Frequently Asked Questions (DATEDIF)

What does the DATEDIF formula do in Excel?

DATEDIF measures the gap between two dates in a unit you choose: "Y" for whole years, "M" for whole months, "D" for days. It is a legacy function that Excel keeps hidden from the function list but still supports, and it remains the cleanest way to compute employee tenure and customer age.

What is the syntax for DATEDIF?
=DATEDIF(start_date, end_date, unit)
What are common mistakes when using DATEDIF?

#NUM!: The start date is later than the end date, which DATEDIF cannot express. (Swap the arguments or guard with IF(B2>C2,0,DATEDIF(B2,C2,"Y")).) Function missing from autocomplete: DATEDIF is a compatibility function and does not appear in the function wizard. (Type it manually — it still works in every Excel version and in Google Sheets.)

Keep building your formula toolkit with these date & time functions.

Browse all 41 Excel formulas
Ready to Master Microsoft Excel?

Master DATEDIF in Intermediate Excel

Learn DATEDIF along with our formula library, practice files, and verifiable certificates in our complete curriculum.

Strictly necessary