WITH t AS ( SELECT sysdate dt FROM dual UNION ALL SELECT TO_DATE('20201221', 'yyyymmdd') FROM dual -- 2020_52 UNION ALL SELECT TO_DATE('20201228', 'yyyymmdd') FROM dual -- 2020_53 UNION ALL SELECT TO_DATE('20210104', 'yyyymmdd') FROM dual -- 2021_01 ) SELECT dt , iyyy , iw , TO_CHAR(iyyy - 1) iyyy_pre , DECODE(TO_CHAR(NEXT_DAY(TO_DATE((iyyy-1)||'01', 'yyyymm') - 1, 5) - 3 + (iw-1)*7, 'iw') , iw, iw, iw-1) iw_pre FROM (SELECT dt , TO_CHAR(dt, 'iyyy') iyyy , TO_CHAR(dt, 'iw') iw FROM t ) ;