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.
For /F "tokens=1 delims= " %%A in ('Date /t') do @(
Set DayName=%%A
)
if('%DayName:~0,3%' equ 'Tue') <run step 31>
When I echo ‘%DayName:~0,3%’ it displays ‘Tue’
You can use this:
Returning “2” is Tuesday.