I want to get the week id for the current date in Snowflake
I tried the Following query.
SELECT to_number(to_char(to_date(current_date),'w')) from dual
This is not working, error : Numeric: value w is not recognized How to solve the problem
Thank you
CodePudding user response:
using WEEKOFYEAR or WEEKISO should be enough. You will want to read the how it week is defined, to make sure it meet your needs.
SELECT
current_date() AS a,
WEEKOFYEAR( a ),
WEEKISO( a )
;
gives:
A | WEEKOFYEAR( A ) | WEEKISO( A ) |
---|---|---|
2022-02-23 | 8 | 8 |
CodePudding user response:
Why not use the WEEK function?