0

我不明白为什么

SELECT YEAROFWEEK('2017-01-01T00:00:00.000+00:00'::timestamp)返回“2016”

SELECT WEEK('2017-01-01T00:00:00.000+00:00'::timestamp)返回“52”

有人可以帮我理解吗?

4

2 回答 2

0

这是决定其工作方式的年度政策的文档 - 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 |
+------+---+
于 2019-11-17T20:35:59.333 回答
0

稍微深入一点,我从https://docs.snowflake.net/manuals/sql-reference/parameters.html#week-of-year-policy得到了答案

于 2019-11-17T18:11:29.913 回答