SQL UPDATE with a Date Data Type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi folks,

I am doing an UPDATE to a table that has a field for a DATE data type. I am
using MS Access.

The UPDATE works fine but when I try to place the DATE field in the mix it
blows up.

The table name is rfi.

Here's a code snippet...
Dim dtNow As DateTime = DateTime.Now
UPDATE [rfi] SET [dateresolved]=dtNow WHERE ([rfi].[id] = @id)

It does not like dtNow, so I tried using dtNow.ToString ( ) which it also
did not like.
Next I changed the data-type for the dateresolved field from DATE to STRING
and tried to put in dtNow.ToString ( ) which it still did not like.

Finally, I hard coded a string in as "8/15/2006" which it accepted both as a
DATE type and as a STRING type.

Any ideas on what I may be missing would be appreciated.

- Glenn
 
glenn,

Were you able to debug to check what value is exactly passed. I guess, this
coould be because of the format of the date. Probably it is trying to pass
'dd/mm/yyyy' whereas your sql server expects 'mm/dd/yyyy' format.

Regards,
Augustin
 
Back
Top