本文介绍了MySQL DAYOFWEEK()-我的星期从星期一开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 DAYOFWEEK( )函数,该函数在星期日返回 1 .但是在我国,一周从星期一开始,而不是星期日.有没有机会从格式如下的MySQL中获取dayofweek:(1-星期一,2-星期二,...)?
I'm using DAYOFWEEK() function in MySQL which returns 1 for sunday. But in my country the week starts with monday, not sunday. Is there any chance to get dayofweek from MySQL formated like: (1 - Monday, 2 - Tuesday, ...) ?
推荐答案
使用WEEKDAY()
代替DAYOFWEEK()
,它从星期一开始.
Use WEEKDAY()
instead of DAYOFWEEK()
, it begins on Monday.
如果您需要从索引1开始,请使用或WEEKDAY() + 1
.
If you need to start at index 1, use or WEEKDAY() + 1
.
这篇关于MySQL DAYOFWEEK()-我的星期从星期一开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!