DECLARE @YYYYMMDD AS VARCHAR(8)='20180308' DECLARE @PREV_YYYY AS VARCHAR(4) --전년도 DECLARE @WK_NUM AS INT --주차 SELECT @PREV_YYYY = CONVERT(VARCHAR(4),CONVERT(INT,LEFT(@YYYYMMDD, 4)-1)) , @WK_NUM = DATEPART(WK, CONVERT(DATE,@YYYYMMDD)) ; WITH DATE_LIST AS ( SELECT CAST (@PREV_YYYY+'-01-01' AS DATETIME) AS DT UNION ALL SELECT DT+1 FROM DATE_LIST WHERE DT+1