DATEDIF function

Returns the number of years, months, or days between two dates.

Syntax

DATEDIF (start date, end date, format)

Computes the difference between start date and end date in the unit specified in format, a code that you enter as text.

Table 1. Format codes for specifying unit returned
Format Unit returned
Y Years
M Months
D Days
MD Days, ignoring months and years
YM Months, ignoring years
YD Days, ignoring years

Example

=DATEDIF("2009-2-1","2010-3-1","YD") returns 29.

=DATEDIF("2010-2-2","2010-3-1","YD") returns 28.