Skip to content
Dropfile

DATEDIF Function

Calculates the difference between two dates in days, months, or years. Commonly used for age calculations and duration tracking.

ExcelGoogle Sheets

Syntax

DATEDIF(start_date, end_date, unit)

Parameters

ParameterDescription
start_dateThe start date (must be earlier than or equal to end_date).
end_dateThe end date.
unit"Y" = years, "M" = months, "D" = days, "MD" = days ignoring months/years, "YM" = months ignoring years, "YD" = days ignoring years.

Examples

Calculate age in years

=DATEDIF(A2, TODAY(), "Y")

Result: 30 (if born 30 years ago)

Months between two dates

=DATEDIF("2024-01-15", "2024-09-20", "M")

Result: 8

Full age display

=DATEDIF(A2,TODAY(),"Y") & " years, " & DATEDIF(A2,TODAY(),"YM") & " months"

Result: 30 years, 5 months

Tips & Best Practices

Related Formulas

Need a different formula?

Describe what you need in plain English and our AI will generate the formula for you.

Try Formula Generator