If you just want to get the DayOfWeek in your computer, you have two simple solutions. The first one is to get it directly from the first word of your %date% variable "Tue 08/18/2015" :)
:
for /F %%a in ("%date%") do set dow=%%a
But if you want to perform the numeric calculation, you may use the method to convert a date into the Julian Day Number shown at this answer:
@echo off
setlocal
rem Modify next line accordingly to your locale format (this one use "Dow MM/DD/YYYY")
for /F "tokens=2-4 delims=/ " %%a in ("%date%") do set /A mm=1%%a-100, dd=1%%b-100, yyyy=%%c
rem Convert the Date to Julian Day Number, and get its Day Of Week (0=Sunday, ..., 6=Saturday)
set /A a=(mm-14)/12, jdn=(1461*(yyyy+4800+a))/4+(367*(mm-2-12*a))/12-(3*((yyyy+4900+a)/100))/4+dd-32075, dow=(jdn+1)%%7
rem Show the result
echo Day of week: %dow%
The set
command use the trick explained in other answers in order to correctly get numbers greater than 07 that start with zero. For example, if the mont is 08
, then set /A mm=1%%a-100
is set /A mm=108-100
, that gives 8.
However, if you want to use this method on different computers, that may have different locale date formats, then you must use the method suggested by foxidrive.