I'm currently trying to map a date column into its day of the week with Monday being 1 and Sunday being 7 by using the following query:
EXTRACT(DAYOFWEEK FROM dates) AS day_of_week
However, according to BQ's documentation, it seems that the function uses Sunday as its first day of the week. Is there any way to elegantly solve this problem without the use of conditional expression in my query and manually adjust the result?
BQ Documentation:
DAYOFWEEK: Returns values in the range [1,7] with Sunday as the first day of the week.
1 + ((EXTRACT(DAYOFWEEK FROM dates) - 2) % 7) AS day_of_week_from_monday. - Akina