Parameter | Type |
---|---|
dateValue | datetimestamp, datetime, date, time, gyear, gyearmonth |
quantity | integer |
units | string |
Returns: date
Example
query:
SELECT DATE_SUB(CAST("2018-01-02" AS DATE), 1, "day")
results:
date_sub |
---|
2018-01-01 |
The date function used to subtract some period of duration from a date or datetime value. Takes three arguments, the original date, a number of units of duration to subtract, and the unit of duration (one of "year", "decade", "century", "quarter", "month", "week", "day", "hour", "minute", "second", or "millisecond").
Parameter | Type |
---|---|
dateValue | datetimestamp, datetime, date, time, gyear, gyearmonth |
quantity | integer |
units | string |
query:
SELECT DATE_SUB(CAST("2018-01-02" AS DATE), 1, "day")
results:
date_sub |
---|
2018-01-01 |