Reputation: 1936
I have a column name late
with datatype time without time zone
. my requirement is to read all the rows which is late more than by 1 hours. I have to query through my rails application. In table column value is like 00:31:00
but in rails it is like
2000-01-01 00:31:00 UTC
. How to query directly or by using ActiveRecords?
Upvotes: 3
Views: 83
Reputation: 2419
When you can directly access the time in rails as '2000-01-01 00:31:00 UTC', then use the code
require 'time'
standard_time_for_comparison = '2000-01-01 00:31:00 UTC'
(Time.now - Time.parse(standard_time_for_comparison))/3600 > 1
Change standard_time_for_comparison according to your needs.
Upvotes: 1