timestampadd

description

Syntax

DATETIME TIMESTAMPADD(unit, interval, DATETIME datetime_expr)

Adds the integer expression interval to the date or datetime expression datetime_expr.

The unit for interval is given by the unit argument, which should be one of the following values:

SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, or YEAR.

example

  1. mysql> SELECT TIMESTAMPADD(MINUTE,1,'2019-01-02');
  2. +------------------------------------------------+
  3. | timestampadd(MINUTE, 1, '2019-01-02 00:00:00') |
  4. +------------------------------------------------+
  5. | 2019-01-02 00:01:00 |
  6. +------------------------------------------------+
  7. mysql> SELECT TIMESTAMPADD(WEEK,1,'2019-01-02');
  8. +----------------------------------------------+
  9. | timestampadd(WEEK, 1, '2019-01-02 00:00:00') |
  10. +----------------------------------------------+
  11. | 2019-01-09 00:00:00 |
  12. +----------------------------------------------+

keyword

TIMESTAMPADD