【问题标题】:Why is extract week from current_date giving wrong week number为什么从 current_date 中提取周给出错误的周数
【发布时间】:2020-08-02 19:35:28
【问题描述】:

select extract(week from current_date) 给出 16,但当前 ISO 周是 17。 这是一个错误还是我做错了什么?上周运行良好。

【问题讨论】:

    标签: sql date select google-bigquery date-arithmetic


    【解决方案1】:

    您可能正在寻找:

    extract(isoweek from current_date)
    

    根据the documentation

    WEEK:返回[0, 53] 范围内日期的周数。周从星期日开始,一年中第一个星期日之前的日期在第 0 周。

    ISOWEEK:返回 date_expression 的 ISO 8601 week 编号。 ISOWEEKs 从星期一开始。返回值在[1, 53] 范围内。每个 ISO 年的第一个 ISOWEEK 从公历年第一个星期四之前的星期一开始。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 2021-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-10
      相关资源
      最近更新 更多