How do I compare only time values using Rails and ActiveRecord? For instance, looking for all rows that were created after 3:00PM?
I tried using Time.parse, however they seem to be expecting a full DateTime value, not Time (11:00 PM etc).
I’m basically looking for all rows that exist between two dates, and then between two times. For example, all rows created between “21/01/2012” and “23/02/2012” that were created after “3:00PM”. The date part seems to work fine, however I don’t seem to be able to get the time part working without plain SQL.
From what I understand you’re applying a function to extract time from a datetime attribute in your SQL. Something like
select HOUR(created_at)…ActiveRecord can’t do that, however the gem squeel does it in Ruby.
But there’s nothing fundamentely different than doing it in plain SQL.