标签:
mysql> select now(); +---------------------+ | now() | +---------------------+ | 2016-06-26 18:39:55 | +---------------------+ 1 row in set (0.17 sec) mysql> select curdate(); +------------+ | curdate() | +------------+ | 2016-06-26 | +------------+ 1 row in set (0.00 sec) mysql> select curtime(); +-----------+ | curtime() | +-----------+ | 18:40:14 | +-----------+ 1 row in set (0.00 sec) mysql> select extract(day from "2012-4-5"); +------------------------------+ | extract(day from "2012-4-5") | +------------------------------+ | 5 | +------------------------------+ 1 row in set (0.18 sec) mysql> select extract(year from "2012-4-5"); +-------------------------------+ | extract(year from "2012-4-5") | +-------------------------------+ | 2012 | +-------------------------------+ 1 row in set (0.00 sec) mysql> select extract(month from "2012-4-5"); +--------------------------------+ | extract(month from "2012-4-5") | +--------------------------------+ | 4 | +--------------------------------+ 1 row in set (0.00 sec)
mysql> select sysdate();
+---------------------+
| sysdate() |
+---------------------+
| 2016-06-26 18:49:15 |
+---------------------+
1 row in set (0.00 sec)
mysql> select date_add("2012-4-5",interval 1 month); +---------------------------------------+ | date_add("2012-4-5",interval 1 month) | +---------------------------------------+ | 2012-05-05 | +---------------------------------------+ 1 row in set (0.00 sec) mysql> select date_add("2012-4-5",interval 1 year); +--------------------------------------+ | date_add("2012-4-5",interval 1 year) | +--------------------------------------+ | 2013-04-05 | +--------------------------------------+ 1 row in set (0.00 sec) mysql> select date_add("2012-4-5",interval 1 day); +-------------------------------------+ | date_add("2012-4-5",interval 1 day) | +-------------------------------------+ | 2012-04-06 | +-------------------------------------+ 1 row in set (0.00 sec) mysql> select date_add("2012-4-5",interval 1 minute); +----------------------------------------+ | date_add("2012-4-5",interval 1 minute) | +----------------------------------------+ | 2012-04-05 00:01:00 | +----------------------------------------+ 1 row in set (0.00 sec) mysql> select date_add("2012-4-5",interval 1 hour); +--------------------------------------+ | date_add("2012-4-5",interval 1 hour) | +--------------------------------------+ | 2012-04-05 01:00:00 | +--------------------------------------+ 1 row in set (0.00 sec)
mysql> select date_add("2012-4-5",interval 1 second);
+----------------------------------------+
| date_add("2012-4-5",interval 1 second) |
+----------------------------------------+
| 2012-04-05 00:00:01 |
+----------------------------------------+
1 row in set (0.00 sec)
mysql> select datediff("2010-7-21","2010-7-28"); +-----------------------------------+ | datediff("2010-7-21","2010-7-28") | +-----------------------------------+ | -7 | +-----------------------------------+ 1 row in set (0.01 sec)
标签:
原文地址:http://www.cnblogs.com/zengkefu/p/5619277.html