Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Big Query get first day of week

I’m working with Big Query and I need to get first day of week.

For example if date = ‘2022-08-26’ I want to have ‘2022-08-22’ where 22 is Monday.

Any solutions please ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks in advance.

>Solution :

To achieve this you’ll want to use the DATE_TRUNC function as follows:

select date_trunc(date('2022-08-26'), WEEK(MONDAY))

You can change the parameter for WEEK to be any day of the week, default is SUNDAY.

Documentation can be found here:
https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#date_trunc

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading