VB6 simple date problem


I am using Windows 2000 professional and Vb6

The command I have tested is as follows:-
'---------------------------------------------------------
Private Sub Command1_Click()
   Dim a As Date
   a = #4/19/2006#
   MsgBox Weekday(a) & " " & WeekdayName(Weekday(a)) & " " & a
End Sub
'---------------------------------------------------------

The result I got from one system is
'4 Thursday 19/04/2006

The result I got from another system is
'4 Wednesday 19/04/2006


I am not able to understand how to resolve this issue.

Hoping for immediate reply.

LVL 5
sriramiyerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mikemCommented:
Try using the  firstdayofweek option (where 1=sunday, 2=monday. etc)..

Weekday(date, [firstdayofweek])

MsgBox Weekday(a) & " " & WeekdayName(Weekday(a)) & " " & a , 1 'Start on Sunday


This should sort the problem as it will use this variable instead of the machine defaults.

Mike
inthedarkCommented:
There are some problems with first day of week if the PC settings are changed. to stop this problem you can use format the dddd gixes you week day name:

msgbox Format(A,"dddd dd/mm/yyyy")


Also this is a good idea, if you PC should be using non-usa date format when you app starts:


If DateSerial(2006,9,11)<>DateValue("11/9/2006") Then
   MsgBox "You regional settings date format is set fo USA mode and may cuase problems when working with databases."
End If

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sriramiyerAuthor Commented:
Thanks to inthedark. It works fine.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.