title: extract data issue
body: <p>I have a table where my env_value = 202052 (2020 is the YYYY and 52 is weeks in a year)
   In the year end after it hits Dec last week which is 202052 then it should start with new year week 
   which is 202101 (env_value)
   With the query i tried it is giving me output as 202053 but i am expecting to see 202101.i am unable to 
   figure out how to do.</p>
  
  <pre><code>  CREATE TABLE env_sys(
      [env_cat] [nvarchar](50) NOT NULL,
      [env_opt] [nvarchar](50) NOT NULL,
      [env_value] [nvarchar](255) NOT NULL)
  
      insert into env_sys 
      values( 'REPORT_EXTRACT', 'LAST_FILE_PROCESSED' , '202052')
  
    select 
  
      rtrim(case when substring(env_value,5,2) between '01' and '08'
      then substring(env_value,1,4)+'0'+cast(cast(substring(env_value,5,2)as int)+1 as char(2))
      when substring(env_value,5,2) between '09' and '52'
    then substring(env_value,1,4)+cast(cast(substring(env_value,5,2)as int)+1 as char(2))
   else
    substring(env_value,1,3)+cast(cast(substring(env_value,4,1)as int)+1 as char(1))+'01' 
   end) 
  from env_sys
  where env_cat = 'REPORT_EXTRACT'
  and env_opt = 'LAST_FILE_PROCESSED'
  </code></pre>