April 2008
Intermediate to advanced
566 pages
21h 55m
English
TIMESTAMPADD()
TIMESTAMPADD(interval,number,datetime)
This function adds the given number of intervals of time to
the given date or time. Intervals that are accepted by this function
are: FRAC_SECOND, SECOND,
MINUTE, HOUR,
DAY, WEEK,
MONTH, QUARTER, and
YEAR. For compatibility with other systems, you can
add the SQL_TSI_ prefix to these interval names
(e.g., SQL_TSI_YEAR for YEAR).
This function is available as of version 5.0.0 of MySQL and is similar
to DATE_ADD(), but the list of intervals accepted
is not exactly the same. Here is an example:
UPDATE appointments SET appointment = TIMESTAMPADD(HOUR, 1, appointment) WHERE appt_id = '8930';
In this example, an appointment is set to an hour later.
Read now
Unlock full access