# Bug in DBI::ODBC: DateTime treated as Date

**URL:** <https://www.ruby-forum.com/t/bug-in-dbi-datetime-treated-as-date/157389>\
**Category:** Ruby\
**Created:** [January 10, 2009, 1:35pm UTC](https://www.ruby-forum.com/t/bug-in-dbi-datetime-treated-as-date/157389 "2009-01-10T13:35:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [January 10, 2009, 1:35pm UTC](https://www.ruby-forum.com/t/bug-in-dbi-datetime-treated-as-date/157389/1 "2009-01-10T13:35:18Z")

</div>

Using DBI::ODBC and it works nicely thank you.

Inserting a value into a column of type SQL datetime.

If the value is ruby type DateTime, it gets truncated to a Date on  
insert. The time portion is lost.

eg 2009-10-01T21:37:14 =\> 2009-10-01 00:00:00.

I think the bug may be in function register\_conversion around line 69 in  
odbc.rb. In the case statement, since DateTime is a subclass of Date,  
the Date branch is taken instead of the DateTime branch.

The fix may be as simple as re-ordering the case branches.

Anyone familiar with the code willing to comment? I’m new to ruby, so  
I’d appreciate it.
