Skip to main content

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​

ParameterDescription
<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 |
+-------------------------------------------------+