title: Subtraction of a number from a variable in a batch script
body: <p>I'm new to batch scripting, so please be lenient with this question. When I'm subtracting 1 from 'TodayDay' variable, the value is not getting updated. Below is the line.</p>
  
  <pre><code>set /a "TodayDay=%TodayDay%-1"
  </code></pre>
  
  <p>My use case is to find if today's date is less than the 'lastOpenedDate' variable, I want to set the 'lastOpenedDate' to yesterday's</p>
  
  <pre><code>set lastOpenedDate=2017-12-22
  IF %TodayYear%-%TodayMonth%-%TodayDay% LSS %lastOpenedDate% (   
    echo Before Subtraction TodayDay is %TodayDay%
    set /a "TodayDay=%TodayDay%-1"
    echo After Subtraction TodayDay is %TodayDay%
  )
  </code></pre>
  
  <p>When I ran the above code, The output is:</p>
  
  <pre><code>Before Subtraction TodayDay is 20
  After Subtraction TodayDay is 20
  </code></pre>
  
  <p>I got the other variable values from the below-mentioned code</p>
  
  <pre><code>for /F "skip=1 delims=" %%F in ('
      wmic PATH Win32_LocalTime GET Day^,Month^,Year /FORMAT:TABLE
  ') do (
      for /F "tokens=1-3" %%L in ("%%F") do (
          set TodayDay=0%%L
          set TodayMonth=0%%M
          set TodayYear=%%N
      )
  )
  set TodayDay=%TodayDay:~-2%
  set TodayMonth=%TodayMonth:~-2%
  </code></pre>
  
  <p>What am I doing wrong?</p>