Name

TIMESTAMPADD( )

Synopsis

TIMESTAMPADD(interval, value, datetime)

This function adds the given interval of time to the given date or time. The intervals accepted 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). This function is available as of Version 5 of MySQL. This function is similar to DATE_ADD( ). In this example, an appointment is set to an hour later.

UPDATE appointments
   SET appointment = TIMESTAMPADD(HOUR, 1, appointment)
   WHERE rec_id = '8930';

Get MySQL in a Nutshell 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.