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
elwayisgodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

elwayisgodAuthor Commented:
result is:

DOW=~16,3

result should be: Thursday
0
Bill PrewCommented:
If you do the following command at a DOS prompt, what does it display?

ECHO %DATE%

~bp
0
elwayisgodAuthor Commented:
'Command' is not recognized as an internal or external command,
operable program or batch file.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

elwayisgodAuthor Commented:
X:\Sam_LREF\EssbaseBackup\maxl>echo %Date%
Thu 08/19/2010
0
elwayisgodAuthor Commented:
I just want the 'Thu' not the rest of it. So my results would always be:

Mon
Tue
Wed
Thu
Fri
Sat
Sun
0
Bill PrewCommented:
In a BAT file, this is all you should need:

@echo off
for /F "tokens=1" %%A in ("%DATE%") do set DOW=%%A

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PeterGillettCommented:
If your echo %date% gives Thu 08/19/2010

then you should be able to use:

SET DOW=%date:~0,3%
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.