DATEDIF Function in Excel

DATEDIF calculates the difference between two dates in years, months, or days.

1 min read · Updated 17 Oct 2026 · By Md. Saiful Islam · বাংলায় পড়ুন

What is the DATEDIF Function

The DATEDIF function calculates the difference between two dates in years, months, or days. It is very useful for calculating age, tenure, and duration. Note that DATEDIF is an undocumented function, so Excel will not autocomplete it, but it works reliably.

Formula: =DATEDIF(start_date, end_date, unit)

Practical Example 1

Birth date in A2, today in B2.

Type: =DATEDIF(A2, B2, Y)

Result: age in full years

Practical Example 2

Calculate months of service for an employee.

Type: =DATEDIF(A2, B2, M)

Result: total months between the two dates

Practical Example 3

Calculate days between two dates.

Type: =DATEDIF(A2, B2, D)

Result: total days between the two dates

Practical Example 4

Calculate completed years and months together using two DATEDIF calls.

Type: =DATEDIF(A2, B2, Y) & years & DATEDIF(A2, B2, YM) & months

Result: a combined age string like 5 years 3 months

When to Use It

DATEDIF is used for age calculation in HR and education, tenure calculation for employees, project duration tracking, service year counting, and any scenario where you need the gap between two dates.

Get one practical IE tip every week

Join IE and production professionals learning with in2eff.