Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB 6 Misinterpreting Dates

Status
Not open for further replies.

Donato

Programmer
Jan 12, 2002
8
CA
I'm having some problems with VB 6 and dates. The regional date setting for my system is set to: dd/MM/yyyy

System info:
PIII 1GHz
Microsoft Windows 2000 Professional 5.00.2195 SP2
Microsoft Visual Studio 6

Here is a sample of code that I ran in the VB 6 immediate window with results:

?Month(#01/05/2002#)
1
?Month(#12/05/2002#)
12
?Month(#13/05/2002#)
5

As you can see the month is the first 2 numbers; not what my regional settings indicate. Once the alleged month increases beyond 12, VB interprets the month to be the next field, 5.

The problem is I think a system wide issue. I have the same problems in MS Access XP, and when running SQL queries in VB on Access tables.

Any suggestions/help is much appreciated.
Thank you.

 
What are you wanting Month(#13/05/2002#) to return? If you want 13, you aren't going to get it because it isn't a valid month. The Month function will only return 1-12. The Month function trys to figure out what date format you are sending it and it is taking your format as dd/mm/yyyy instead of mm/dd/yyyy.

What exactly are you trying to accomplish, there is probably another way of doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top