I'm trying to extract the week number of the month for any given date. If the month starts on a Saturday, it should be labelled 0. Thereafter, the weeks will be labelled 1, 2, 3, ...
For example, for Jan 2022, 1st Jan is Week 0, 2nd Jan is Week 1, 9th Jan is Week 2, 16 Jan is Week 3, 23 Jan is Week 4, and 30th Jan is Week 4.
I tried converting some MS SQL & TSQL codes from other Stack Overflow questions but it did not work on Snowflake.
I guess the alternative is to hardcode using Sunday dates but the code is far too long and has too many conditions. Hoping for a shorter, cleaner code using Snowflake's inbuilt SQL functions.