elwayisgod
asked on
Windows Batch - Find Day of Week
Hi,
I have the below batch script to create the 'DOW' variable. However when I run it, it's choking on the 4th lineon the 'Command' part. Not sure what is wrong. Any help? Prefer to keep this Windows Batch. Running on Win Server 2003 R2.
REM Set the Day of Week (DOW) Variable
:: setDOW.bat
@echo off
Echo.|Command /C Date>DOW
set /p today=<DOW
set DOW=%today:~16,3%
echo DOW=%DOW%
:: DONE
I have the below batch script to create the 'DOW' variable. However when I run it, it's choking on the 4th lineon the 'Command' part. Not sure what is wrong. Any help? Prefer to keep this Windows Batch. Running on Win Server 2003 R2.
REM Set the Day of Week (DOW) Variable
:: setDOW.bat
@echo off
Echo.|Command /C Date>DOW
set /p today=<DOW
set DOW=%today:~16,3%
echo DOW=%DOW%
:: DONE
If you do the following command at a DOS prompt, what does it display?
ECHO %DATE%
~bp
ECHO %DATE%
~bp
ASKER
'Command' is not recognized as an internal or external command,
operable program or batch file.
operable program or batch file.
ASKER
X:\Sam_LREF\EssbaseBackup\ maxl>echo %Date%
Thu 08/19/2010
Thu 08/19/2010
ASKER
I just want the 'Thu' not the rest of it. So my results would always be:
Mon
Tue
Wed
Thu
Fri
Sat
Sun
Mon
Tue
Wed
Thu
Fri
Sat
Sun
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If your echo %date% gives Thu 08/19/2010
then you should be able to use:
SET DOW=%date:~0,3%
then you should be able to use:
SET DOW=%date:~0,3%
ASKER
DOW=~16,3
result should be: Thursday