VeloDB Cloud
SQL Manual
Functions
date-time-functions
years_sub

years_sub

Description

Syntax:

DATETIME YEARS_SUB(DATETIME date, INT years)

This function subtracts the specified years from the given date.

date can be of DATE or DATETIME type, and the returned result is of the same type as date.

Example

mysql> select years_sub("2020-02-02 02:02:02", 1);
+-------------------------------------+
| years_sub('2020-02-02 02:02:02', 1) |
+-------------------------------------+
| 2019-02-02 02:02:02                 |
+-------------------------------------+

Keywords

YEARS_SUB