1.

Solve : Day of the Week?

Answer»

Quote from: Reno on March 16, 2009, 04:03:28 AM

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...


Quote
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:

Quote
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



Discussion

No Comment Found