title: Run parts of a batch file based on the day of the week
body: <p>I am running a dos batch file in SQL Server Agent job.  I have 34 steps in the batch file.  All steps run every day EXCEPT step 31.  It only runs on Tuesday.  I could setup another SQL Agent Job, but that seems like overkill.  How can I query the system for the day of the week in the batch file in order to run Step 31 on Tuesday only?  I tried the below code but had not luck.</p>
  
  <pre><code>For /F "tokens=1 delims= " %%A in ('Date /t') do @( 
  Set DayName=%%A 
  ) 
  
  if('%DayName:~0,3%' equ 'Tue') &lt;run step 31&gt;
  </code></pre>
  
  <p>When I echo '%DayName:~0,3%' it displays 'Tue'</p>