title: Oracle SQL Get previous month from 6 digit number NUMBER
body: <p>The month field is YYYYMM in the form of a NUMBER.
  I want to get the previous month. I already calculate the previous month to December if the current month is January Eg: 201301 gets converted to 201212. (I use MOD to check last if last two digits get evaluated to 1, if yes, it decrements year and appends 12 as the month)</p>
  
  <p>I'm trying to get the previous month if the current month is any month other than January. For this I tried-</p>
  
  <pre><code>  1) select  CONCAT( SUBSTR(201405,1,4),  MOD(201405,100) - 1 )  from dual;
    2) select  CONCAT( SUBSTR(201405,1,4),  SUBSTR(201405,5,6) - 1 )  from dual;
  </code></pre>
  
  <p>In both the cases it returns 20144, i.e it drops the 0 from the current month. So for the value of 201405, the it should return 201404.</p>