前端之家收集整理的这篇文章主要介绍了
MySQL 日期时间函数常用总结,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_0@获得当前日期+时间(date+time)1.1函数:now()
@H_
301_0@相关
函数:current_timestamp(),localtime(),localtimestamp()
@H_
301_0@举例说明:
@H_
301_0@

@H_
301_0@2.获得当前日期(date)
@H_
301_0@
函数:curdate()
@H_
301_0@相关
函数:current_date(),current_date
@H_
301_0@举例说明:
@H_
301_0@

@H_
301_0@3.获得当前时间(time)
@H_
301_0@
函数:curtime()
@H_
301_0@相关
函数:current_time(),current_time
@H_
301_0@举例说明
@H_
301_0@

@H_
301_0@4.
MysqLdayof…
@H_
301_0@
函数:dayofweek(),dayofmonth(),dayofyear()分别返回日期参数,在一周、一月、一年中的位置。
@H_
301_0@举例说明
@H_
301_0@set@dt='2008-08-08';
@H_
301_0@selectdayofweek(@dt);--6
@H_
301_0@selectdayofmonth(@dt);--8
@H_
301_0@selectdayofyear(@dt);--221
@H_
301_0@日期‘2008-08-08′是一周中的第6天(1=Sunday,2=Monday,…,7=Saturday)
@H_
301_0@一月中的第8天;一年中的第221天