一、日期时间函数
字符串函数 |
描述 |
curdate() |
返回当前时间的年月旦 |
curtime() |
返回当前时间的时分秒 |
now() |
返回当前时间的日期和时间 |
month(x) |
返回日期×中的月份值 |
week(x) |
返回日期×是年度第几个星期 |
hour(x) |
返回×中的小时值 |
minute(x) |
返回×中的分钟值 |
second(x) |
返回×中的秒钟值 |
dayofweek(x) |
返回×本周第几天 |
dayofmonth(x) |
计算日期×是本月的第几天 |
dayofyear(x) |
计算日期×是本年的第几天 |
(root@localhost) [(none)]> select curdate(); 查看当前日期
(root@localhost) [(none)]> select curtime(); 查看当前时间
(root@localhost) [(none)]> select now(); 查看现在的日期和时间
(root@localhost) [(none)]> select month(now()); 查看当前月,可写'2021-08-11'
(root@localhost) [(none)]> select week(now()); 查看第几周
(root@localhost) [(none)]> select hour(now()); 查看几时
(root@localhost) [(none)]> select minute(now()); 查看现在多少分钟
(root@localhost) [(none)]> select second(now()); 查看多少秒
(root@localhost) [(none)]> select dayofweek(now()); 查看今天是这周的第几天,星期天算第一天
(root@localhost) [(none)]> select dayofmonth(now()); 查看今天是这个月的第几天
(root@localhost) [(none)]> select dayofyear(now())