Update syntax error?

H

h3llz

"UPDATE tblBaskets SET timestamp='" & Now() & "' WHERE basketID=" & basketID
& ";"

if i update the timestamp it gives a syntax error :< timestamp is Date/Time
with general date
 
D

Dirk Goldgar

h3llz said:
"UPDATE tblBaskets SET timestamp='" & Now() & "' WHERE basketID=" &
basketID
& ";"

if i update the timestamp it gives a syntax error :< timestamp is
Date/Time
with general date


Use the # delimiter with date/time values:

"UPDATE tblBaskets SET timestamp=#" & _
Now() & "# WHERE basketID=" & basketID & ";"

Note, though, that the date will be interpreted as being in month/day/year
format if that interpretation results in a valid date, even if you are
accustomed to day/month/year format.

You should probably explicitly format the Now() value to avoid any
ambiguity:

"UPDATE tblBaskets SET timestamp=#" & _
Format(Now(), "mm/dd/yyyy hh:nn:ss") & _
"# WHERE basketID=" & basketID & ";"
 
F

fredg

"UPDATE tblBaskets SET timestamp='" & Now() & "' WHERE basketID=" & basketID
& ";"

if i update the timestamp it gives a syntax error :< timestamp is Date/Time
with general date

Dates are delimitated with the # symbol, i.e.
timestamp = #12/10/2008 12:50:00 PM#

Your code delimits the Now() as though it were a string (text) value.

Try:

"UPDATE tblBaskets SET tblBaskets.timestamp= #" & Now() & "# WHERE
basketID=" & basketID & ";"

The above should be all on one line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top