MySQL TIMESTAMP()
MySQL 날짜함수, 시간함수
TIMESTAMP()
- argument에 대한 datetime 값을 return, argument가 2개인경우는 더해서 datetime 값을 return.
TIMESTAMP(expr), TIMESTAMP(expr1, expr2)
의 형태
With a single argument, this function returns the date or datetime expression expr as a datetime value. With two arguments, it adds the time expression expr2 to the date or datetime expression expr1 and return the result as a datetime value.
mysql> SELECT TIMESTAMP(NOW());
+---------------------+
| TIMESTAMP(NOW()) |
+---------------------+
| 2020-04-04 10:14:51 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT TIMESTAMP('2020-04-02');
+-------------------------+
| TIMESTAMP('2020-04-02') |
+-------------------------+
| 2020-04-02 00:00:00 |
+-------------------------+
1 row in set (0.00 sec)
mysql> SELECT TIMESTAMP('2020-04-02 23:00:00');
+----------------------------------+
| TIMESTAMP('2020-04-02 23:00:00') |
+----------------------------------+
| 2020-04-02 23:00:00 |
+----------------------------------+
1 row in set (0.00 sec)
mysql> SELECT TIMESTAMP('2002-12-21 12:00:00', '12:00:00') ;
+----------------------------------------------+
| TIMESTAMP('2002-12-21 12:00:00', '12:00:00') |
+----------------------------------------------+
| 2002-12-22 00:00:00 |
+----------------------------------------------+
1 row in set (0.00 sec)