Reputation: 751
What can i do to query records by the time in a date time field? And by "time," i mean the time without the date. For example, I want every record that's created at midnight of any day.
Upvotes: 2
Views: 904
Reputation: 1534
More like this:
Product.where("time(created_at) = time(?)", Time.new(2008,6,21, 24,0,0, '-00:00'))
EDIT
I added the timezone param to Time.new, that param should match the timezone you have your date time fields in your database.
Upvotes: 3