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

Problem with inserting date field into MySQL with VB6

Status
Not open for further replies.

sane79

MIS
Nov 18, 2003
60
SG
Hi all.. I have a problem with inserting a date field from VB into MySQL.

The entered value in MYSQL shows 0000-00-00

This is what I have in VB

Dim SDateFormat As String
SDateFormat = "YYYY0-MM-DD"

"INSERT INTO CUSTOMER (DOB)
VALUES (" & Format$(dtDOB, SDateFormat) & ")"

Can anyone advise me on what is wrong here pls?
Thanks
 
Two things that you can check. First is,

Code:
... = "YYYY0-MM-DD"

a typo in the post or in your code? Make sure it is "YYYY-MM-DD".

Second, does the string need to be surrounded by some kind of quotes, as it does in other databases, which may depend on the data type. (I am not familiar with MySQL)? If so try,

Code:
... VALUES ('" & Format$(dtDOB, SDateFormat) & "')"


Take Care,

zemp
 
What is the error you are receiving? If you aren't getting an actual error and your result is just an incorrect date in the MySQL CUSTOMER table, what is that bad value?
 
Opps typo mistake on my side..
problem solved!
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top