VeloDB Cloud
SQL Manual
Functions
date-time-functions
date_sub

date_sub

Description

Syntax:

INT DATE_SUB(DATETIME date,INTERVAL expr type)

This function subtracts the specified time interval from the date.

date is a valid date expression.

expr is the interval you want to add.

type can be any of the followings: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND

Example

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

Keywords

Date, date, date