多语言展示
当前在线:716今日阅读:60今日分享:41

MySQL日期时间函数总结

MySQL中常用的日期时间函数。
工具/原料
1

电脑

2

MySql

方法/步骤
1

获得当前日期+时间(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()分别返回日期参数,在一周、一月、一年中的位置,日期‘2008-08-08′ 是一周中的第6 天(1 = Sunday, 2 = Monday, …, 7 = Saturday)一月中的第8 天;一年中的第221 天

5

例子:给出西元0年至今多少天返回DATE值(不计算1582年以前)。根据format字符串格式化date值(在format字符串中可用标志符)END

推荐信息