日期函数的详解,MySQL内置时间curdate查询用法

时间:2020-01-25 04:27来源:江苏十一选五手机版数据库
mysql的日期函数. 例子中当前日期: curdate() 是2013年6月24日。 YEAR() :显示年 mysql select year(curdate()); +-----------------+ |year(curdate()) | +-----------------+ | 2013 | +-----------------+ 1 rowin set (0.01 sec)

mysql的日期函数. 例子中当前日期:curdate() 是2013年6月24日。 YEAR() :显示年 mysql select year(curdate()); +-----------------+ | year(curdate()) | +-----------------+ | 2013 | +-----------------+ 1 row in set (0.01 sec) MONTH() :显示月 mysql select month(curdate()); +------------------+ | month(curdate()) | +------------------+ |6 | +------------------+ 1 row in set (0.00 sec) DAYOFMONTH():显示日期 mysql select dayofmonth(curdate()); +-----------------------+ | dayofmonth(curdate()) | +-----------------------+ | 24 | +-----------------------+ 1 row in set (0.08 sec)

总结一下MySQL内置时间查询用法

mysql> SELECT year(curdate());
+-----------------+
| year(curdate()) |
+-----------------+
| 2009 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT month(curdate());
+------------------+
| month(curdate()) |
+------------------+
| 8 |
+------------------+
1 row in set (0.00 sec)

mysql> SELECT day(curdate());
+----------------+
| day(curdate()) |
+----------------+
| 9 |
+----------------+
1 row in set (0.00 sec)

mysql> SELECT curdate();
+------------+
| curdate() |
+------------+
| 2009-08-09 |
+------------+
1 row in set (0.00 sec)

mysql> SELECT dayofmonth(curdate());
+-----------------------+
| dayofmonth(curdate()) |
+-----------------------+
| 9 |
+-----------------------+
1 row in set (0.00 sec)

mysql SELECT year(curdate()); +-----------------+ | year(curdate()) | +-----------------+ | 2009 | +-----------------+ 1 row in set (0.00 s...

编辑:江苏十一选五手机版数据库 本文来源:日期函数的详解,MySQL内置时间curdate查询用法

关键词: