# Is DateTime and Time interchangeable?

**URL:** <https://www.ruby-forum.com/t/is-datetime-and-time-interchangeable/139093>\
**Category:** Rails\
**Created:** [May 30, 2008, 6:32pm UTC](https://www.ruby-forum.com/t/is-datetime-and-time-interchangeable/139093 "2008-05-30T18:32:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_LIn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@Eric\_LIn](https://www.ruby-forum.com/u/Eric_LIn)\
**Post date:** [May 30, 2008, 6:32pm UTC](https://www.ruby-forum.com/t/is-datetime-and-time-interchangeable/139093/1 "2008-05-30T18:32:25Z")

</div>

I have datetime (SQL) column in my DB, and I noticed whenever I  
retrieve that column using ActiveRecord, it returns an object of class  
Time instead of DateTime. Does Rails convert treat datetime and time  
as if they’re the same?

Eric

---

<div class="post-metadata">

**Author:** ![Eric\_LIn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@Eric\_LIn](https://www.ruby-forum.com/u/Eric_LIn)\
**Post date:** [May 30, 2008, 6:47pm UTC](https://www.ruby-forum.com/t/is-datetime-and-time-interchangeable/139093/2 "2008-05-30T18:47:11Z")

</div>

On May 30, 5:20 pm, Eric LIn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have datetime (SQL) column in my DB, and I noticed whenever I  
> retrieve that column using ActiveRecord, it returns an object of class  
> Time instead of DateTime. Does Rails convert treat datetime and time  
> as if they’re the same?

Time and DateTime are not the same, but the behave mostly the same  
(and Time is what you get by default for a datetime column).  
Ruby’s Time and DateTime are not different in the way that a  
database’s time and datetime are (ruby does not have a pure time of  
day class).

Fred
