DAYS_SUB
Descriptionβ
Subtracts a specified time interval to the date.
Aliasβ
ε«εβ
- days_sub
- date_sub
- subdate
Syntaxβ
DATE_SUB(<date>, <expr> <time_unit>)
Parametersβ
Parameter | Description |
---|---|
<date> | A valid date value |
<expr> | The time interval you want to subtract |
<type> | Enumerated values: YEAR, QUARTER, MONTH, DAY, HOUR, MINUTE, SECOND |
Return Valueβ
Returns the calculated date.
Examplesβ
select date_sub('2010-11-30 23:59:59', INTERVAL 2 DAY);
+-------------------------------------------------+
| date_sub('2010-11-30 23:59:59', INTERVAL 2 DAY) |
+-------------------------------------------------+
| 2010-11-28 23:59:59 |
+-------------------------------------------------+