Reference/Functions/
DATE_DIFF
The date function used to returns the difference between two date or datetime values as a given unit of duration. Takes three arguments, the start date, the end date, and the unit of duration (one of "year", "decade", "century", "quarter", "month", "week", "day",
"hour", "minute", "second", or "millisecond").
Parameter | Type |
---|
dateValue1 | datetimestamp, datetime, date, time, gyear, gyearmonth |
dateValue2 | datetimestamp, datetime, date, time, gyear, gyearmonth |
units | string |
Returns: integer
Example
query:
SELECT DATE_DIFF(CAST("2018-01-02" AS DATE), CAST("2018-01-05" AS DATE), "day")
results: