Created
May 23, 2025 02:55
-
-
Save seahrh/945373d94a753282d73bb8aa0ca99660 to your computer and use it in GitHub Desktop.
BigQuery date extract: WEEK vs ISOWEEK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#extract | |
SELECT EXTRACT(WEEK FROM DATE '2024-12-31') -- 52 | |
,EXTRACT(ISOWEEK FROM DATE '2024-12-31') -- 1, this could be incorrectly counted as week 1 in year 2024 | |
,EXTRACT(WEEK FROM DATE '2025-01-01') -- 0 | |
,EXTRACT(ISOWEEK FROM DATE '2025-01-01') -- 1 | |
,EXTRACT(WEEK FROM DATE '2023-12-31') -- 53 | |
,EXTRACT(ISOWEEK FROM DATE '2023-12-31') -- 52 | |
,EXTRACT(WEEK FROM DATE '2024-01-01') -- 0 | |
,EXTRACT(ISOWEEK FROM DATE '2024-01-01') -- 1 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment