When you're on TD13.10 you can use a SQL UDF, otherwise simply use the calculation:
REPLACE FUNCTION WEEK_BEGIN(cdate DATE)
RETURNS DATE
SPECIFIC week_begin_DA
RETURNS NULL ON NULL INPUT
CONTAINS SQL
DETERMINISTIC
COLLATION INVOKER
INLINE TYPE 1
RETURN
cdate-(((cdate - DATE '0001-01-01')) MOD 7)
This returns the begin of the week, so
SELECT WEEK_BEGIN(DATE)-1
simply subtract one:
When you're on TD13.10 you can use a SQL UDF, otherwise simply use the calculation:
This returns the begin of the week, so
simply subtract one: