웹이야기

MySQL TIMESTAMPADD() 본문

D/MySQL

MySQL TIMESTAMPADD()

yeon.Biju 2020. 4. 4. 10:26

MySQL 날짜함수, 시간함수

 

TIMESTAMPADD()

   - 

 

TIMESTAMPADD(unit, interval, 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: MICROSECOND(microseconds), SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR.

 

The unit value may be specified unsing on of keywords as shown, or with a prefix of SQL_TSI_.

For example, DAY and SQL_TSI_DAY both are legal.

 

mysql> SELECT TIMESTAMPADD(WEEK, 1, '2002-01-02');
+-------------------------------------+
| TIMESTAMPADD(WEEK, 1, '2002-01-02') |
+-------------------------------------+
| 2002-01-09                          |
+-------------------------------------+
1 row in set (0.00 sec)


mysql> SELECT TIMESTAMPADD(MINUTE, 1, '2002-01-02');
+---------------------------------------+
| TIMESTAMPADD(MINUTE, 1, '2002-01-02') |
+---------------------------------------+
| 2002-01-02 00:01:00                   |
+---------------------------------------+
1 row in set (0.00 sec)

 

mysql> SELECT TIMESTAMPADD(WEEK, 1, NOW());
+------------------------------+
| TIMESTAMPADD(WEEK, 1, NOW()) |
+------------------------------+
| 2020-04-11 10:26:30          |
+------------------------------+
1 row in set (0.00 sec)

'D > MySQL' 카테고리의 다른 글

MySQL TIME_FORMAT()  (0) 2020.04.04
MySQL TIMESTAMPDIFF()  (0) 2020.04.04
MySQL TIMESTAMP()  (0) 2020.04.04
MySQL TIMEDIFF()  (0) 2020.04.03
MySQL TIME()  (0) 2020.04.03
Comments