The DATEDIF function returns the number of days, months, or years between two dates.

Syntax

=DATEDIF(start_date,end_date,unit)

Arguments

Argument Description
start_date Start date in Excel date serial number format
end_date End date in Excel date serial number format
unit The time unit to use (years, months, or days)

  Y difference in complete years
  M difference in complete months
  D difference in days
  MD difference in days, ignoring months and years
  YM difference in months, ignoring days and years
  YD difference in days, ignoring years

Examples

  A B C D E F
1 Start date End date Unit Formula Result Notes
2 1/1/2010 3/1/2013 Y =DATEDIF(A2,B2,C2) 3 Difference in complete years
3     M =DATEDIF(A2,B2,C3) 38 Difference in complete months
4     D =DATEDIF(A2,B2,C4) 1155 Difference in days
5     MD =DATEDIF(A2,B2,C5) 0 Difference in days, ignoring months and years
6     YM =DATEDIF(A2,B2,C6) 2 Difference in months, ignoring days and years
7     YD =DATEDIF(A2,B2,C7) 59 Difference in days, ignoring years

Usage note:

  • The DATEDIF function is a “compatability” function that comes from Lotus 1-2-3. For reasons unknown, it is only documented in Excel 2000, but you can use it in your formulas in all Excel versions since that time.