rails-sqlserver/tiny_tds — Issue #65: DateTime Conversion Issue
Author: Altonymous
Created: 2011-12-04 06:46:55+00:00
State: open

When querying a SWL Server 2008 database for a date time field, it is converting the date to Time appropriately, however, it is truncating the milliseconds off the request. This causes and issue when you are looking for a delta of records since the last query by date.

For instance:

First Query:

SELECT TOP 1 StartedOn, CompletedOn FROM [Table] ORDER BY RequestID DESC

SELECT * FROM [Table] WHERE (StartedOn > '#{started_on.strftime "%Y-%m-%d %H:%M:%S:%L"}' OR CompletedOn > '#{completed_on.strftime "%Y-%m-%d %H:%M:%S:%L"}') ORDER BY RequestID ASC

If you remove the %L from the format it always returns the record from the first result since the milliseconds are greater than no milliseconds.