SUBDATE(date,INTERVAL expression type)

Description: Returns the date that results from subtracting an interval expression from date (a DATE or DATETIME type), where the interval is of type. The formatting principles are the same as for ADDDATE(), and expected formats for expression are as shown previously in Table C.1.

SUBDATE() is synonymous with DATE_SUB() and -.

Examples:

  • SUBDATE('2002-01-05',INTERVAL 3 DAY) returns 2002-01-02.

  • SUBDATE('2002-01-05 12:00:00',INTERVAL 3 DAY) returns 2002-01-02 12:00:00.

  • SUBDATE('00-02-07 09:00:00',INTERVAL 36 HOUR) returns 2000-02-05 21:00:00.

  • SUBDATE('2002-06-01',INTERVAL "37 6" YEAR_MONTH) returns 1964-12-01.

See also: DATE_SUB(), ADDDATE()

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.