years_sub
years_subβ
descriptionβ
Syntaxβ
DATETIME YEARS_SUB(DATETIME date, INT years)
Subtracts a specified number of years from a datetime or date
The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter 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