Error with Dates in SQL Server

An application that run without flaw last week has been reported to
crash with an error that says that a conversion from char to datetime
has given a date outside range.

This very application runs OK today in production (fortunately :-),
and the difference in both SQL Servers is just that the one where the
exception has started to appear has Spanish conventions. I can’t give
better details because I develop in a Mac and have zero experience
with SQL Server. Of course this is not an ideal development
context :-), but am a bit lost because of that. The exact trace is
copied below.

This sounds like some day is being interpreted as a month by the SQL
Server in Spanish, can I fix that in a database-agnostic way? This is
a pretty standard usage of AR with migrations and Date objects
assigned to some fields. I saw the SQL Server adapter transforms them
into datetimes. Everything works flawlessly except for that problem.

– fxn

DBI::DatabaseError: 22008 (242) [Microsoft][ODBC
SQL Server Driver][SQL Server]La conversi¾n del tipo de datos char a
datetime p
odujo un valor datetime fuera de intervalo.: INSERT INTO movimientos
([carpeta]
[otras_caracteristicas], [fecha_valor], [importe_operacion],
[fecha_operacion]
[oficina], [referencia_1], [remite], [referencia_2], [divisa],
[concepto], [cr
ado_en], [cuenta], [concepto_especifico], [entidad], [saldo],
[estado]) VALUES(
53386185’, ‘C00607-060714-105544-0095’, ‘2006-07-14’, 235500,
‘2006-07-14’, ‘23
5 - POZUELO DE ALARCON - ESTACION - AV. JUAN PABLO II, 5 ‘, ‘’,
‘REMPO’, ‘’, ‘E
R’, ‘INGRESO POR VALIDAR’, ‘2006-07-14 11:07:15’,
‘21002128420200179838’, ‘’, ’
aCaixa’, 4110278, ‘N’) (ActiveRecord::StatementInvalid)
from ./script/…/config/…/vendor/rails/activerecord/lib/
active_record/
onnection_adapters/sqlserver_adapter.rb:279:in insert' from ./script/../config/../vendor/rails/activerecord/lib/ active_record/ ase.rb:1739:increate_without_callbacks’
from ./script/…/config/…/vendor/rails/activerecord/lib/
active_record/
allbacks.rb:261:in create_without_timestamps' from ./script/../config/../vendor/rails/activerecord/lib/ active_record/ imestamp.rb:30:increate’
from ./script/…/config/…/vendor/rails/activerecord/lib/
active_record/
ase.rb:1718:in create_or_update_without_callbacks' from ./script/../config/../vendor/rails/activerecord/lib/ active_record/ allbacks.rb:249:increate_or_update’
from ./script/…/config/…/vendor/rails/activerecord/lib/
active_record/
ase.rb:1392:in save_without_validation' from ./script/../config/../vendor/rails/activerecord/lib/ active_record/ alidations.rb:724:insave_without_transactions’
… 10 levels…
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:21:in e al' from ./script/../config/../vendor/rails/railties/lib/ commands/runner.rb 27 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:21:inr
quire’
from
script/runner:3_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

On Friday, July 14, 2006, at 10:34 PM, Xavier N. wrote:

exact trace is copied below.
SQL Server Driver][SQL Server]La conversi�n del tipo de datos char a
‘2006-07-14’, ‘23
ase.rb:1739:in `create_without_callbacks’
active_record/
al’
http://lists.rubyonrails.org/mailman/listinfo/rails
If you have an intel mac you can get a copy of parallels and win xp and
install SQL server on that.

_Kevin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs