为什么从 current_date 中提取周数给出了错误的周数

Why is extract week from current_date giving wrong week number

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

您可能正在寻找:

extract(isoweek from current_date)

根据the documentation:

WEEK: Returns the week number of the date in the range [0, 53]. Weeks begin with Sunday, and dates prior to the first Sunday of the year are in week 0.

ISOWEEK: Returns the ISO 8601 week number of the date_expression. ISOWEEKs begin on Monday. Return values are in the range [1, 53]. The first ISOWEEK of each ISO year begins on the Monday before the first Thursday of the Gregorian calendar year.