[Table of Contents] [docx version]

SpreadsheetML Reference Material - Table of Contents

DATEDIF

Syntax:

DATEDIF ( start-date , end-date , unit )

Description: Calculates the number of days, months, or years between two dates.

Arguments:

Name

Type

Description

start-date

number

The first date in the period, truncated to integer.

end-date

number

The last date in the period, truncated to integer.

unit

text

The count to be returned, as follows:

Value

Day Count Basis

"Y"

The number of complete years in the period.

"M"

The number of complete months in the period.

"D"

The number of days in the period.

"MD"

The difference between the days in start-date and end-date. The months and years of the dates are ignored.

"YM"

The difference between the months in start-date and end-date. The days and years of the dates are ignored.

"YD"

The difference between the days of start-date and end-date. The years of the dates are ignored.

 

 

Return Type and Value: number – The number of days, months, or years between two dates, depending on the value of unit.

However, if

start-date or end-date is out of range for the current date base value, #NUM! is returned.

start-date ≥ end-date #NUM! is returned.

unit is any value other than those shown in the table above, #NUM! is returned.

[Example:

DATEDIF(DATE(2001,1,1),DATE(2003,1,1),"Y") results in 2 complete years
DATEDIF(DATE(2001,6,1),DATE(2002,8,15),"D") results in 440 days
DATEDIF(DATE(2001,6,1),DATE(2002,8,15),"YD") results in 75 days
DATEDIF(DATE(2001,6,1),DATE(2002,8,15),"MD") results in 14 days

end example]