VeloDB Cloud
SQL Manual
Functions
date-time-functions
months_sub

months_sub

Description

Syntax:

DATETIME MONTHS_SUB(DATETIME date, INT months)

This function subtracts the specified number of months 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 months_sub("2020-02-02 02:02:02", 1);
+--------------------------------------+
| months_sub('2020-02-02 02:02:02', 1) |
+--------------------------------------+
| 2020-01-02 02:02:02                  |
+--------------------------------------+

Keywords

MONTHS_SUB