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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help ! I have problem with the way VB handles date

Status
Not open for further replies.

hiptino

Programmer
May 27, 2000
18
0
0
NG
I set the system Regional Setting to English, date format to "dd/mm/yyyy".

In my application,
A textbox accepts date input from a user: "05/02/2001"

A query statement uses [# Cdate("05/02/2001") #] to update a date-type field in a transaction table (access database).
When the transactions are retrieved into a listbox for viewing the date field now appears like this;

0 john 02/05/2001 $20.00
1 mac 02/05/2001 $24.00
3 stela 02/05/2001 $54.00

The day and the month were swapped.
I don't know if the problem is from Access Db or Visual basic.

Any suggestion as to rectify this ?

 
The Cdate function could be the culprit. It could be converting the date into the us english type of "mm/dd/yyyy."

There is a format function available. Look up Format in MSDN.

The syntax is something like below:

dim x as string
x = "1/10/2001"
format(x, "dd/mm/yyyy")

You should also check to see if the data within the Access Database is stored in the format you specified durin the insert.

I hope this helps.

bye
Jim
 
Dim TestDate As Date

With my Table
TestDate = !Burtday ' the field of the table

TestDate = Format(TestDate,"dd/mm/yyyy")

ListBox1.AddItem TestDate Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
I had written a little conversion function to do the above (what a pain - I assume microsoft had now easy solution for UK dates or VB and VBA would handle them better).

I couldn't work out why my date filters didnt work and spent some time pulling (my already sparse) hair out.

Thanks for the pointers above for the format func its probably quicker (and easier) than my func.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top