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!

Date inserted to table does not match value of SQL stmt 1

Status
Not open for further replies.

kellbell

Technical User
Jun 20, 2007
12
US
I have written code to update the [Date] field of a table. According to Debug.Print, my SQL statement appears to be retrieving the correct information, but when I open the corresponding table, the date entered does not match. My code is
Code:
 strSQLUpdate = "UPDATE tblTotalDealerMetrics " & _
                   "SET [Date] =  " & dteDate & " ; "

The Debug.Print reveals
Code:
UPDATE tblTotalDealerMetrics SET [Date] =  12/31/2006 ;

However, the value appearing in the table is 12/30/1899.

dteDate is set as a date variable. I also tried setting it as a string, but that didn't have good results either.

Any ideas on what I am doing wrong? Thanks in advance.
 
That would be:
Code:
strSQLUpdate = "UPDATE tblTotalDealerMetrics " & _
                   "SET [Date] =  #" & dteDate & "# ; "

If you are using American date formats, all should be well, if not it is necessary to format the date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top