0

Currently I connect to a MSSQL database by activerecord-sqlserver-adapter on top of dbd-odbc and tiny_tds.

INSERT is working, except for DATETIME field.

The datetime field returned from a SELECT:

rows = ActiveRecord::Base.connection.select_rows("SELECT * from customer")

in the result:

rows.first[5]
=> Wed Jan 11 00:00:00 UTC 1984

It gives an error if I use the same DATETIME value to INSERT a new row:

ODBC::Error: 22008 (241) [unixODBC][FreeTDS][SQL Server]Syntax error converting datetime from character string.

Where can I specify how DATETIME field are formatted?

meda
  • 45,103
  • 14
  • 92
  • 122
ohho
  • 50,879
  • 75
  • 256
  • 383

1 Answers1

0

What you are inserting is a String. You have specified TIMESTAMP datatype in MsSQL. You have to match datatype in both program and database. Either change your MsSQL to Varchar datatype or in your program take date datatype.

user2550754
  • 884
  • 8
  • 15