MySQL 日期时间函数常用总结

前端之家收集整理的这篇文章主要介绍了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天

    猜你在找的PHP相关文章