雪花中的日期函数似乎无法正常工作

时间:2019-11-17 18:01:07

标签: snowflake-data-warehouse snowflake-schema

我不明白为什么

DropdownButton<String>( isExpanded: true, item: dropdownItems, //Other stuff here ) 返回“ 2016”

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

有人可以帮助我理解吗?

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分: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 |
+------+---+