Home / Microsoft / Microsoft DOS / Day of the Week
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: Day of the Week  (Read 1167 times)
BC_Programmer
Mastermind


Thanked: 697
Posts: 15,881

Computer: Specs
Experience: Beginner
OS: Windows 7


Pinkie Pie is best pony

BC-Programming.com 1 1
« Reply #15 on: March 16, 2009, 05:26:03 PM »

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  ;D

IP logged

My Blog

BASeBlock 2.3.0 (NOW WITH MACGUFFINS!)
Pages: 1 [2]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / Day of the Week « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.095 seconds with 19 queries.