Since you don't want to answer to the very valid tamil's question about your NLS_TERRITORY setting, I'll assume you are in one of those territories where week starts on MONDAY. (If according to your NLS settings your week starts on SUNDAY, you'll have to modify the following function accordingly):
Code:CREATE OR REPLACE FUNCTION my_non_iso_week (p_date DATE) RETURN INTEGER IS l_first_day CHAR(1); l_result NUMBER(2); BEGIN l_first_day := TO_CHAR(TRUNC(p_date, 'YYYY'), 'D'); IF TO_CHAR(p_date, 'D') >= l_first_day THEN l_result := TO_NUMBER(TO_CHAR(p_date, 'WW')); ELSE l_result := TO_NUMBER(TO_CHAR(p_date, 'WW'))+1; END IF; RETURN l_result; END;




Reply With Quote