It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                6年前关闭。
            
                    
我正在使用MySQL的week()函数从日期确定星期数。我面临的问题是,它总是比实际周数少返回一个数。假设今天是2013年5月15日,因为它是今年的第20周,但结果是19。以下是我正在使用的查询。

 SELECT *,WEEK(date_visit) AS week_no FROM property_view_details;

最佳答案

直接来自docs

mysql> SELECT WEEK('2008-02-20',1);
    -> 8


您可以通过将第二个参数分别设置为0索引或1索引结果的WEEK0来更改1的行为。

10-07 19:49
查看更多