• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

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.

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

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
sriramiyerAuthor Commented:
Thanks to inthedark. It works fine.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now