mysql时间函数之dayofweek,dayofmonth,dayofyear,weekofyear用法

语法

DAYOFWEEK(date)

Returns the weekday index for date (1 = Sunday, 2 = Monday, …, 7 = Saturday). These index values correspond to the ODBC standard.

返回日期的工作日索引(1 =星期日,2 =星期一,…,7 =星期六)。 这些索引值对应于ODBC标准。


DAYOFMONTH(date)

Returns the day of the month for date, in the range 1 to 31, or 0 for dates such as ‘0000-00-00’ or ‘2008-00-00’ that have a zero day part.

返回日期的月的天数的索引,范围为1到31,或者对于日期(例如“0000-00-00”或“2008-00-00”)的日期为零的日期返回0。


DAYOFYEAR(date)

Returns the day of the year for date, in the range 1 to 366.

返回日期的年中的天数的索引,范围为1到366。


WEEKOFYEAR(date)

Returns the calendar week of the date as a number in the range from 1 to 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).

返回日期的日历星期数作为范围从1到53的数字。WEEKOFYEAR()是一个兼容性函数,等同于WEEK(日期,3)。



实例

SELECT dayofweek('2011-12-14');     # 4
SELECT dayofmonth('2011-12-14');    # 14
SELECT dayofmonth('2011-12-00');    # 0
SELECT dayofyear('2011-12-14');     # 348
SELECT weekofyear('2011-12-14');    # 50

你可能感兴趣的:(【mysql】)