PDA

View Full Version : Calling date from Windows 2000


dror2002
08-05-2003, 08:10 AM
Hi All,

I have a problem. My VB code calls the date function to retrieve the date on the local machine. It works fine on windows XP, but in windows 2000 it returns the correct date but the WEEKDAY is wrong - one day ahead, meaning if today is Tuesday Aug 5-th then I get Wednesday Aug 5-th. What should I do? Have you ever met the problem before?

DNAunion2000
08-05-2003, 10:42 PM
/*DNAunion*/ Have you checked the actual computers' dates?

dror2002
09-04-2003, 08:26 AM
Hi everybody,

I found out that my mistake did not relate to the platform but to my code. I used the VB function of WEEKDAYNAME (which receives two parameters, a date and another optional one I didn't know about.). The optional parameter determines the first day of the week (which can be different worldwide). Suprisingly, VB assumes by default Sunday as the first day of the week. So I got the wrong day since in the date parameter the day is held with a number from 1 to 7. The solution is calling the function with the optional parameter as the constant vbMonday (if Monday is your first day of the week), but a better solution, if you want your application to be accurate on any computer worldwide, is to simply use (what I think should be VB's default) - the constant vbUseSystemDefault for this optional argument...

Just To let you know,

Cheers.