DATEDIFF

Returns the number of date and time boundaries crossed between two specified dates.

For example, you can use this function to find the number of days in a certain interval of dates.

Note: This function is equivalent to DATEDIFF in T-SQL.

Return Value

Integer

Syntax

DATEDIFF( datePart, startDate, endDate )

where:

  • datePart specifies the part of the dates on which to calculate the difference.

    Possible values for this argument include these:

    • year - yyyy
    • month - m
    • week - ww
    • day - d
    • weekday - w
    • dayofyear - y
    • hour - h
    • minute - n
    • second - s
  • startDate is the beginning date for the calculation.
  • endDate is the ending date for the calculation.

The startDate value is subtracted from the endDate.

Note: If the startDate is later than the endDate, then the return value is a negative number. If the result is out of range for integer values, the system returns an error.