the first solution you post at 1:50 failed on year<1900 and year>2100
why does it fail?
Oh hold on... I think I know why...
For /f "delims==" %%N in ( ' cscript //nologo evaluate.vbs "weekday("1/1/2009")" ' ) do set daynumber=%%N
For /f "delims==" %%D in ( ' cscript //nologo evaluate.vbs "weekdayname(weekday("1/1/2009"))" ' ) do set dayofweek=%%D
Instead of enclosing the dates as a string, use date literals:
For /f "delims==" %%N in ( ' cscript //nologo evaluate.vbs "weekday(#1/1/2009#)" ' ) do set daynumber=%%N
For /f "delims==" %%D in ( ' cscript //nologo evaluate.vbs "weekdayname(weekday(#1/1/2009#))" ' ) do set dayofweek=%%D
tests seem to work from the year 100 to 9999, with various month and day combinations.
Not to take away from the pure batch solution of course
