I have a situation where using Snowflake, I need to construct a date from these parts (year, weekOfYear, dayOfWeek). ie (2022, 13th week, 3 for Weds) would equate to today's date 2022-03-30.
While this is possible in say Pandas, Snowflake's day_from_parts()
does not seem to support this functionality. Is there some other method to construct a date from these 3 pieces of information?
For context, I am ultimately trying to create flags in my dimDate for 'weekToDate' and 'weekToDatePrevYear' (the prev year comparison is not actually the same date, but instead is Mon - today's dayOfWeek of the same weekOfYear, prev year). The flags must also account for weeks that span across two year's, and leap years with 53 weeks (in which case it will be compared to the 52nd week of prev year). The date I need to construct is the previous year's comparisonDate to today, from parts:
(year(current_date())-1, min(weekOfYear(current_date()), 52), dayOfWeek(current_date()))
Thanks in advance for any suggestions!