DATEDIFF

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

For example, you could 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 the following:
    • year, yy, yyyy
    • quarter, q, qq
    • month, m, mm
    • week, wk, ww
    • day, d, dd
    • weekday, dw
    • dayofyear, dy, y
    • hour, hh
    • minute, mm, n
    • second, ss, s
    • millisecond, ms
  • 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.