Mysql TIMESTAMPADD
From w3cyberlearnings
Contents |
MySQL TIMESTAMPADD Function
This function adds integer expression to date or datetime expression.
Syntax TIMESTAMPADD
- Unit: A given unit for interval to be added
- MICROSECOND
- SECOND
- MINUTE
- HOUR
- DAY
- WEEK
- MONTH
- QUARTER
- YEAR
- Interval: integer expression
- expre: date or datetime expression
TIMESTAMPADD(UNit, Interval, expre);
Example 1
mysql> SELECT TIMESTAMPADD(HOUR,3,'2012-04-24 02:30:00'); +--------------------------------------------+ | TIMESTAMPADD(HOUR,3,'2012-04-24 02:30:00') | +--------------------------------------------+ | 2012-04-24 05:30:00 | +--------------------------------------------+ 1 row in set (0.00 sec)
Example 2
mysql> SELECT TIMESTAMPADD(DAY,3,'2012-04-24 02:30:00'); +-------------------------------------------+ | TIMESTAMPADD(DAY,3,'2012-04-24 02:30:00') | +-------------------------------------------+ | 2012-04-27 02:30:00 | +-------------------------------------------+ 1 row in set (0.00 sec)