Update syntax error?

  • Thread starter Thread starter h3llz
  • Start date Start date
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
 
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 & ";"
 
"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.
 
Back
Top