April 2008
Intermediate to advanced
566 pages
21h 55m
English
ADDDATE()
ADDDATE(date, INTERVALvaluetype) ADDDATE(date,days)
This function adds the given interval of time to the date or
time provided. This is a synonym for
DATE_ADD(); see its definition later in this
chapter for details and interval types. The second, simpler syntax is
available as of version 4.1 of MySQL. This shorthand syntax does not
work, though, with DATE_ADD(). Here is an
example:
UPDATE seminars SET seminar_date = ADDDATE(seminar_date, INTERVAL 1 MONTH) WHERE seminar_date = '2007-12-01'; UPDATE seminars SET seminar_date = ADDDATE(seminar_date, 7) WHERE seminar_date = '2007-12-15';
The first SQL statement postpones a seminar that was scheduled for December 1, 2007 to a month later (January 1, 2008). The second statement postpones the seminar on December 15 to December 22, seven days later.
Read now
Unlock full access