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: