Link to home
Start Free TrialLog in
Avatar of elwayisgod
elwayisgodFlag for United States of America

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
Avatar of elwayisgod
elwayisgod
Flag of United States of America image

ASKER

result is:

DOW=~16,3

result should be: Thursday
Avatar of Bill Prew
Bill Prew

If you do the following command at a DOS prompt, what does it display?

ECHO %DATE%

~bp
'Command' is not recognized as an internal or external command,
operable program or batch file.
X:\Sam_LREF\EssbaseBackup\maxl>echo %Date%
Thu 08/19/2010
I just want the 'Thu' not the rest of it. So my results would always be:

Mon
Tue
Wed
Thu
Fri
Sat
Sun
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If your echo %date% gives Thu 08/19/2010

then you should be able to use:

SET DOW=%date:~0,3%