Apple numbers User Manual

Page of 295
Chapter 12   
 Dictionary of Functions
225
 
DATEDIF
The DATEDIF function finds the number of days, months, or years between two dates.
DATEDIF(start-dateend-datemethod)
 start-date:  The starting date.
 end-date:  The ending date.
 method:  Specifies whether the time difference is expressed in years, months, or days 
and how the calculation handles dates in different years or months:
"D" counts the days between the dates.
"M" counts the months between the dates.
"Y" counts the years between the dates.
"MD" counts the days between the starting and ending days of the month, ignoring 
months and years. If the starting day is after the ending day, the count starts from 
the ending day as if it were in the preceding month. The year of the end-date is used 
to check for a leap year.
"YM" counts the number of whole months between start-date and end-date, ignoring 
the year. If the starting month/day is before the ending month/day, the dates are 
treated as though they are in the same year. If the starting month/day is after the 
ending month/day, the dates are treated as though they are in consecutive years.
"YD" counts the number of days between the starting month/day and ending 
month/day, ignoring years.
  
Examples
If A1 contains "4/6/88" and A2 contains "10/30/06" then: 
  
DATEDIF(A1,A2,"D") returns 6781, the number of days between April 6, 1988, and October 30, 2006.
DATEDIF(A1,A2,"M") returns 222, the number of whole months between April 6, 1988, and October 30, 
2006.
DATEDIF(A1,A2,"Y") returns 18, the number of whole years between April 6, 1988, and October 30, 
2006.
DATEDIF(A1,A2,"MD") returns 24, the number of days between the sixth day of a month and the 
thirtieth day of the same month.
DATEDIF(A1,A2,"YM") returns 6, the number of months between April and the following October in 
any year.
DATEDIF(A1,A2,"YD") returns 207, the number of days between April 6 and the following October 30 in 
any year.
DATEDIF(A1,NOW(),"Y") & " years, " & DATEDIF(A1,NOW(),"YM") & " months, and " & 
DATEDIF(A1,NOW(),"MD") & " days" returns the current age of someone born on April 6, 1988.