如何使YEARWEEK()将星期日视为一周的开始? [英] How To Get YEARWEEK() To See Sunday As The Start Of The Week?

查看:551
本文介绍了如何使YEARWEEK()将星期日视为一周的开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用YEARWEEK函数,以将周日视为一周的第一天.

I'm trying to get the YEARWEEK function to see Sunday as the 1st day of the week.

示例日期为:2009年3月1日,星期日

An example date is: Sunday 1st Mar 2009

这是我的SQL

SELECT YEARWEEK('2009-03-01')

结果是

-> 200909

第9周是哪个星期.我认为这是第9周,因为它将星期日视为上一周的最后一天.

Which is week 9. I believe it is telling me this is week 9 because it sees the sunday as the last day of the previous week.

我如何获取此功能以将星期日视为一周的第一天并因此返回至第十周?

How would I get this function to see sunday as the 1st day of the week and therefore return as week 10?

推荐答案

根据

According to http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_yearweek, YEARWEEK has an optional second argument which controls this. YEARWEEK('2009-03-01', 0) should do what you want (but see the table of possible values under WEEK on that page).

这篇关于如何使YEARWEEK()将星期日视为一周的开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆