SUBDATE(date,INTERVAL expr unit) : SUBDATE « Date Time Functions « MySQL Tutorial






The following table shows the expected form of the expr argument for each unit value.

unit ValueExpected expr Format
MICROSECONDMICROSECONDS
SECONDSECONDS
MINUTEMINUTES
HOURHOURS
DAYDAYS
WEEKWEEKS
MONTHMONTHS
QUARTERQUARTERS
YEARYEARS
SECOND_MICROSECOND'SECONDS.MICROSECONDS'
MINUTE_MICROSECOND'MINUTES.MICROSECONDS'
MINUTE_SECOND'MINUTES:SECONDS'
HOUR_MICROSECOND'HOURS.MICROSECONDS'
HOUR_SECOND'HOURS:MINUTES:SECONDS'
HOUR_MINUTE'HOURS:MINUTES'
DAY_MICROSECOND'DAYS.MICROSECONDS'
DAY_SECOND'DAYS HOURS:MINUTES:SECONDS'
DAY_MINUTE'DAYS HOURS:MINUTES'
DAY_HOUR'DAYS HOURS'
YEAR_MONTH'YEARS-MONTHS'


14.40.SUBDATE
14.40.1.SUBDATE(date,INTERVAL expr unit)
14.40.2.SELECT SUBDATE('1998-01-02', INTERVAL 31 DAY);
14.40.3.SUBDATE(expr,days): The second form allows the use of an integer value for days