DATEDIFF adds a specified interval to a date or time value.

Syntax

DATEDIFF (intervalType , startDate , endDate )

Arguments

  • intervalType: any of these interval types: MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR.
  • startDate, endDate: the start and end dates for the interval, in any expression that can be resolved to a DATE or TIMESTAMP data type.

Returns

  • An INTEGER expression of the difference for the interval and intervalType.

Examples

datediff(MONTH, date('2013-05-13'), date('2013-07-13'))

-- Returns
2