• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • 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.

0
sriramiyer
Asked:
sriramiyer
1 Solution
 
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
0
 
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
0
 
sriramiyerAuthor Commented:
Thanks to inthedark. It works fine.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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