blob: 2d97cb082477689984e36a64ce05d61c0779ecb4 [file] [log] [blame] [view]
---
{
"title": "TIMESTAMPADD",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## 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
```
mysql> SELECT TIMESTAMPADD(MINUTE,1,'2019-01-02');
+------------------------------------------------+
| timestampadd(MINUTE, 1, '2019-01-02 00:00:00') |
+------------------------------------------------+
| 2019-01-02 00:01:00 |
+------------------------------------------------+
mysql> SELECT TIMESTAMPADD(WEEK,1,'2019-01-02');
+----------------------------------------------+
| timestampadd(WEEK, 1, '2019-01-02 00:00:00') |
+----------------------------------------------+
| 2019-01-09 00:00:00 |
+----------------------------------------------+
```
### keywords
TIMESTAMPADD