How do I group by clock in Postgres and Rails? I have read some SO answers, but I am getting errors.
This works when grouping by date:
Model.group("date(updated_at)").count
Then I tried the following for an hour, but they did not work:
Model.group("hour(updated_at)").count Model.group("date_format(updated_at, '%H')").count Model.group("extract(hour from updated_at)").count
As soon as I found a few hours, I need to update, how can I get models with this watch? I.e:
Model.where("hour(updated_at) = ?", 5)
source share