We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

VB6 simple date problem

sriramiyer
sriramiyer asked
on
Medium Priority
349 Views
Last Modified: 2011-04-14

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.

Comment
Watch Question

Commented:
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
CERTIFIED EXPERT
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks to inthedark. It works fine.


Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.