I’ve a problem with SQL Server and Rails.
Rails and SQL Server seems to save date format in different ways:
Rails way: 2011-12-15
SQL Server: 15-12-2011
As I’m running SQL Server in Brazilian Portuguese so my problem might exist only for brazilian people.
Whenever I do any Model.save on Rails, I’m getting this error:
A conversão de um tipo de dados varchar em um tipo de dados
datetime resultou em um valor datetime fora do intervalo.: <my query here>
As Rails insert/update the created_at and updated_at columns, I always get this error.
Does anyone knows how to solve this?
I’m running jRuby on activerecord-jdbcmssql-adapter.
it’s dead simple…just create a file under config/initializer with the name you want, I use datetime_format.rb. With this line:
This will overwrite the default datetime format for the DB.