我不明白为什么
SELECT YEAROFWEEK('2017-01-01T00:00:00.000+00:00'::timestamp)
返回“2016”
SELECT WEEK('2017-01-01T00:00:00.000+00:00'::timestamp)
返回“52”
有人可以帮我理解吗?
我不明白为什么
SELECT YEAROFWEEK('2017-01-01T00:00:00.000+00:00'::timestamp)
返回“2016”
SELECT WEEK('2017-01-01T00:00:00.000+00:00'::timestamp)
返回“52”
有人可以帮我理解吗?
这是决定其工作方式的年度政策的文档 - https://docs.snowflake.net/manuals/sql-reference/parameters.html#week-of-year-policy
一个例子可能会有所帮助。在新创建的帐户上, week_of_year_policy默认设置为 0。
select YEAROFWEEK('2017-01-01T00:00:00.000+00:00'::timestamp) as yow
, WEEK('2017-01-01T00:00:00.000+00:00'::timestamp) as w;
+------+----+
| YOW | W |
+------+----+
| 2016 | 52 |
+------+----+
alter session set week_of_year_policy = 1;
select YEAROFWEEK('2017-01-01T00:00:00.000+00:00'::timestamp) as yow
, WEEK('2017-01-01T00:00:00.000+00:00'::timestamp) as w;
+------+---+
| YOW | W |
+------+---+
| 2017 | 1 |
+------+---+