# SQLServer Timestamp parsing problem in sqlserver\_adapter.rb

**URL:** <https://www.ruby-forum.com/t/sqlserver-timestamp-parsing-problem-in-sqlserver-adapter-rb/95988>\
**Category:** Rails\
**Created:** [June 21, 2006, 8:33pm UTC](https://www.ruby-forum.com/t/sqlserver-timestamp-parsing-problem-in-sqlserver-adapter-rb/95988 "2006-06-21T20:33:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 21, 2006, 8:33pm UTC](https://www.ruby-forum.com/t/sqlserver-timestamp-parsing-problem-in-sqlserver-adapter-rb/95988/1 "2006-06-21T20:33:44Z")

</div>

So, I’ve used Rails to tie into a legacy system which is on SQL Server  
2000 with a required timestamp field, DBTimeStamp. The field is defined  
in SQL Server as type timestamp, but when rails is pulling it in, it  
appears it may be casting to a datetime format. So, when I try to read  
or  
write to the field, it gives me a parsing error:

NoMethodError: private method ‘gsub!’ called for [0, 0, 0, 0, 0, 0, 224,  
43]:Array  
from c:/ruby/lib/ruby/1.8/date/format.rb:253:in ‘\_parse’  
from c:/ruby/lib/ruby/1.8/parsedate.rb:9:in ‘parsedate’  
from  
c:/ruby/lib/ruby/1.8/gems/activerecord-1.14.2/lib/active\_record\_cnnection\_adapters/sqlserver\_adapter.rb:92:in  
‘cast\_to\_time’  
from  
c:/ruby/lib/ruby/1.8/gems/activerecord-1.14.2/lib/active\_record\_cnnection\_adapters/sqlserver\_adapter.rb:82:in  
‘type\_cast’

```
...

```

I think the problem comes down to sqlserver\_adapter.rb, in the type\_cast  
method, asking timestamps to cast\_to\_time instead of something that  
SQLServer is expecting. My questions are two:

1. Does it look like I’ve traced this right?
2. Who knows how a timestamp record needs to be casted in SQLServer?

I’ve looked at the data in a third-party tool, and it doesn’t give me  
much: data of type BYTES (binary data?). I’ve spent quite a bit of time  
over at Microsoft’s site today, but it seems they’ve either started  
moving  
things around, or they’ve got some servers under maintenance, because  
I’ve  
got blind links everywhere.

Thanks in advance for your comments.
