Cellwise

Dates function

Excel DATEDIF function

DATEDIF counts the complete years, months, or days between two dates. It is the go-to way to work out someone's age or years of service. Excel does not show it in autocomplete, but it works when you type it.

fx=DATEDIF(start_date, end_date, unit)

Arguments

start_date
The earlier date.
end_date
The later date. It must be on or after the start date.
unit
"Y" for complete years, "M" for complete months, "D" for days.

DATEDIF examples

Every result below was calculated live from this sample sheet.

ABC
1MemberJoinedRenewal
2Grace Lin2019-08-202026-03-01
3Omar Haddad2023-11-052026-05-04
4Ines Duarte2025-12-152026-06-15
  1. fx=DATEDIF(B2,C2,"Y")

    Result: 6

    Grace had 6 complete years of membership at renewal.

  2. fx=DATEDIF(B3,C3,"M")

    Result: 29

    Omar had 29 complete months. The last month was one day short.

  3. fx=DATEDIF(B4,C4,"D")

    Result: 182

    Ines had 182 days between joining and renewal.

  4. fx=DATEDIF(B2,TODAY(),"Y")

    Result: today’s date-based value

    Complete years from joining until today, like an age formula.

  5. fx=DATEDIF(C2,B2,"Y")

    Result: #NUM!

    If the start date is later than the end date you get #NUM!.

How to use DATEDIF

  1. Click the cell for the result.
  2. Type =DATEDIF( and click the start date.
  3. Type a comma and click the end date.
  4. Add the unit in quotes, like "Y", and press Enter.

Common DATEDIF mistakes

Dates in the wrong order

The start date must come first and be the earlier date, or DATEDIF returns #NUM!.

Forgetting the quotes around the unit

Type "Y", "M" or "D" with quotes. Without them Excel returns #NAME?.

Thinking the function is missing

DATEDIF does not appear in autocomplete or the function list. Type it in full and it still works.

DATEDIF FAQ

How do I calculate age in Excel from a date of birth?

Use =DATEDIF(B2,TODAY(),"Y"). It returns completed years, so the age only goes up on the birthday.

Why can't I find DATEDIF in Excel?

It is an older compatibility function that Excel keeps but does not list. Type =DATEDIF( by hand and it works.

How do I calculate years of service in Excel?

Use =DATEDIF(hire_date,TODAY(),"Y") for whole years, or "M" for whole months.

Practice DATEDIF in these lessons

Guides that use DATEDIF

Related functions

Updated 2026-10-31