DATE_SUB(date,INTERVAL expr unit)
Performs date arithmetic. The date argument specifies the starting date or datetime value. expr is an expression specifying the interval value to be added or subtracted from the starting date. expr is a string; it may start with a "-
" for negative intervals. unit is a keyword indicating the units in which the expression should be interpreted. See Date and Time Units for a complete list of permitted units.
See also DATE_ADD()
.
SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY); +-----------------------------------------+ | DATE_SUB('1998-01-02', INTERVAL 31 DAY) | +-----------------------------------------+ | 1997-12-02 | +-----------------------------------------+
SELECT DATE_SUB('2005-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND); +----------------------------------------------------------------+ | DATE_SUB('2005-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND) | +----------------------------------------------------------------+ | 2004-12-30 22:58:59 | +----------------------------------------------------------------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/date_sub/