title: .bat file not working properly, want to keep leading zero
body: <p>I am getting invalid number.Numeric constants are either decimal(17),hexadecimal(0x11),or octal(021). It also keeps renaming it 20161201_2012312016 even though I am running now when it should be 20160801_20160831. I've pasted code. Thanks</p>
  
  <pre><code>@echo off
  
  set FirstDay=01
  
  set /a Month=%date:~4,2%-1
  set Month=0%Month%
  set Month=%Month:~-2%
  
  set Year=%date:~10,4%
  
  if %Month%==00 (
    set Month=12
    set /a Year=%Year%-1
  )
  
  if %Month%==01 set "LastDay=31" &amp; goto foundate
  if %Month%==02 set "LastDay=28" &amp; goto foundate
  if %Month%==03 set "LastDay=31" &amp; goto foundate
  if %Month%==04 set "LastDay=30" &amp; goto foundate
  if %Month%==05 set "LastDay=31" &amp; goto foundate
  if %Month%==06 set "LastDay=30" &amp; goto foundate
  if %Month%==07 set "LastDay=31" &amp; goto foundate
  if %Month%==08 set "LastDay=31" &amp; goto foundate
  if %Month%==09 set "LastDay=30" &amp; goto foundate
  if %Month%==10 set "LastDay=31" &amp; goto foundate
  if %Month%==11 set "LastDay=30" &amp; goto foundate
  if %Month%==12 set "LastDay=31" &amp; goto foundate
  
  
  
  :foundate
  echo The year is: %Year%
  echo The month is: %Month%
  echo First day of this month is: %FirstDay%
  echo Last day of this month is: %LastDay%
  
  set FileDir=Z:\"EpicCare Reports"\Reports_Team\Scheduled_Reports_Output \PreUHC\
  
  
  set fileext=.txt
  set Ifile=CPT_000318_
  set ofile=%ifile%%Year%%Month%%FirstDay%_%Year%%Month%%Lastday%%fileext%
  
  echo Output Filename: %ofile%
  ren %FileDir%%ifile%.txt %ofile% 
  
    move /Y %FileDir%%ofile% Z:\"EpicCare Reports"\Reports_Team\Scheduled_Reports_Output\UHC\
  </code></pre>