웹이야기

MySQL TIMESTAMP() 본문

D/MySQL

MySQL TIMESTAMP()

yeon.Biju 2020. 4. 4. 10:18

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)

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

MySQL TIMESTAMPDIFF()  (0) 2020.04.04
MySQL TIMESTAMPADD()  (0) 2020.04.04
MySQL TIMEDIFF()  (0) 2020.04.03
MySQL TIME()  (0) 2020.04.03
MySQL SYSDATE()  (0) 2020.04.03
Comments