1.当前的时间:now()
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2020-10-20 10:17:25 |
+---------------------+
1 row in set (0.00 sec)
2.当前年月日
curdate()
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2020-10-20 |
+------------+
1 row in set (0.00 sec)
3.当前的时刻
curtime();
mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 10:22:33 |
+-----------+
1 row in set (0.00 sec)
4.当前的月、周
注:没有current_week()函数
mysql> select current_week();
ERROR 1305 (42000): FUNCTION test_01.current_week does not exist
这里使用year()、month()等函数进行提取。
mysql> select month('1996-10-29');
+---------------------+
| month('1996-10-29') |
+---