TIMESTAMPADD(unit,interval,datetime_expr) adds the integer expression interval to datetime_expr : TIMESTAMPADD « Date Time Functions « MySQL Tutorial






The unit for interval is given by the unit argument.

The unit value may be specified with a prefix of SQL_TSI_.

For example, DAY and SQL_TSI_DAY both are legal.

The unit should be one of the following values:

  1. FRAC_SECOND,
  2. SECOND,
  3. MINUTE,
  4. HOUR,
  5. DAY,
  6. WEEK,
  7. MONTH,
  8. QUARTER, or
  9. YEAR.
mysql>
mysql>
mysql> SELECT TIMESTAMPADD(MINUTE,1,'2003-01-02');
+-------------------------------------+
| TIMESTAMPADD(MINUTE,1,'2003-01-02') |
+-------------------------------------+
| 2003-01-02 00:01:00                 |
+-------------------------------------+
1 row in set (0.02 sec)








14.46.TIMESTAMPADD
14.46.1.TIMESTAMPADD(unit,interval,datetime_expr) adds the integer expression interval to datetime_expr
14.46.2.SELECT TIMESTAMPADD(SECOND,1,'2003-01-02');
14.46.3.SELECT TIMESTAMPADD(FRAC_SECOND,1,'2003-01-02');
14.46.4.SELECT TIMESTAMPADD(HOUR,1,'2003-01-02');
14.46.5.SELECT TIMESTAMPADD(DAY,1,'2003-01-02');
14.46.6.SELECT TIMESTAMPADD(WEEK,1,'2003-01-02');
14.46.7.SELECT TIMESTAMPADD(MONTH,1,'2003-01-02');
14.46.8.SELECT TIMESTAMPADD(QUARTER,1,'2003-01-02');
14.46.9.SELECT TIMESTAMPADD(YEAR,1,'2003-01-02');