ADDDATE(date,INTERVAL expression type)

Description: Returns the date that results from adding an interval expression to date (a DATE or DATETIME type), where the interval is of type as shown in Table C.1.

If date is of type DATE and type contains only year, month, and day calculations, a date will result; if date is of type DATETIME or type includes hour, minute, or second calculations, a date and time will result.

ADDDATE() is synonymous with DATE_ADD() and +.

Table C.1. Values for expression and type When Adding and Subtracting Time Using ADDDATE(), SUBDATE(), and Synonymous Functions
Value of typeFormat for expression
SECONDss
MINUTEmm
HOURhh
DAYDD
MONTHMM
YEARYY
MINUTE_SECOND"mm:ss"
HOUR_MINUTE"hh:mm:ss"
DAY_HOUR"DD hh"
YEAR_MONTH"YY-MM"
HOUR_SECOND"hh:mm:ss"
DAY_MINUTE"DD hh:mm"
DAY_SECOND"DD hh:mm:ss"

Examples:

  • ADDDATE('2002-01-05',INTERVAL 3 DAY) returns 2002-01-08.

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

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

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

See also: DATE_ADD(), SUBDATE()

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.48.181