MySQL日期时间函数常用总结
<div id="cnblogs_post_body">[*] 获得当前日期+时间(date + time)1.1 函数:now()
[*] 相关函数:current_timestamp(),localtime(),localtimestamp()
[*] 举例说明:
[*]http://f.hiphotos.baidu.com/space/pic/item/d52a2834349b033b368b217215ce36d3d539bd13.jpg
2. 获得当前日期(date)
[*] 函数:curdate()
[*] 相关函数:current_date(),current_date
[*] 举例说明:
[*]http://g.hiphotos.baidu.com/space/pic/item/7af40ad162d9f2d3696cf947a9ec8a136327cc1d.jpg
3. 获得当前时间(time)
[*]函数:curtime()
[*] 相关函数:current_time(),current_time
[*]举例说明
[*]http://d.hiphotos.baidu.com/space/pic/item/6a600c338744ebf87976b997d9f9d72a6059a717.jpg
4. MySQL dayof&hellip;
[*]函数:dayofweek(), dayofmonth(), dayofyear()分别返回日期参数,在一周、一月、一年中的位置。
[*]举例说明
[*]set @dt = '2008-08-08';
[*]select dayofweek(@dt); -- 6
[*]select dayofmonth(@dt); -- 8
[*]select dayofyear(@dt); -- 221
[*]日期&lsquo;2008-08-08&prime; 是一周中的第6 天(1 = Sunday, 2 = Monday, &hellip;, 7 = Saturday)
[*]一月中的第8 天;一年中的第221 天
页:
[1]