MySQL 日期时间函数常用总结
程序员文章站
2022-05-24 18:44:47
...
获得当前日期+时间(date + time)1.1 函数:now()
相关函数:current_timestamp(),localtime(),localtimestamp()
举例说明:
2. 获得当前日期(date)
函数:curdate()
相关函数:current_date(),current_date
举例说明:
3. 获得当前时间(time)
函数:curtime()
相关函数:current_time(),current_time
举例说明
4. MySQL dayof…
函数:dayofweek(), dayofmonth(), dayofyear()分别返回日期参数,在一周、一月、一年中的位置。
举例说明
set @dt = '2008-08-08';
select dayofweek(@dt); -- 6
select dayofmonth(@dt); -- 8
select dayofyear(@dt); -- 221
日期‘2008-08-08′ 是一周中的第6 天(1 = Sunday, 2 = Monday, …, 7 = Saturday)
一月中的第8 天;一年中的第221 天
推荐阅读
-
mysql 时间转换函数的使用方法第1/2页
-
mysql的数值、字符、时间日期三种数据类型介绍
-
Java日期时间API系列12-----Jdk8中java.time包中的新的日期时间API类,日期格式化,常用日期格式大全
-
java基础--常用函数总结
-
JavaScript常用正则验证函数实例小结【年龄,数字,Email,手机,URL,日期等】
-
浅谈linux下的一些常用函数的总结(必看篇)
-
javascript 格式化时间日期函数代码脚本之家修正版
-
php和mysql关于时间的实用函数
-
PL/SQL 日期时间类型函数及运算
-
ms sql server中实现的unix时间戳函数(含生成和格式化,可以和mysql兼容)