I am trying to extract week from date using the function
format_timestamp('%V', DATE)
but Bigquery documentation says "Monday as the first day of the week".
Is there a way where I can specify Tuesday as first day of week.
I have achieved the same in Redshift using
date_part(week, date + interval '-1 day')
Is it possible in Bigquery?
Below is for BigQuery Standard SQL
You can use WEEK(WEEKDAY) as shown below
#standardSQL
SELECT FORMAT_TIMESTAMP('%V', CURRENT_TIMESTAMP()),
EXTRACT(WEEK(SATURDAY) FROM CURRENT_TIMESTAMP())
This was introduced quite recently - https://cloud.google.com/bigquery/docs/release-notes#november_30_2017
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With