postgresql - PG::Error with group_date gem in rails -
i have been using getting hourly info of 1 day, have tried this
@getting_each_day = order.group_by_hour_of_day("2014-08-22 00:00:00").count
but showing error postgresql.....
pg::error: error: syntax error @ or near "00" line 1: ...unt() count_all, extract(hour 2014-08-22 00:00:00::... ^ : select count() count_all, extract(hour 2014-08-22 00:00:00::timestamptz @ tim zone 'asia/muscat' - interval '0 hour')::integer hour_of_day "orders" (2014- 08-22 00:00:00 not null) grouping extract(hour 2014-08-22 00:00:00::timestamptz @ time zone 'asia/muscat' - interval '0 hour')::integer
but working order.group_by_hour_of_day(:created_at).count
is there wrong query, have tried timezone, getting same,
you can utilize grouping (without using gem) specifying target day in clause:
order.where('date(created_at) = ?', "2014-08-22").select('extract(hour created_at)').group('extract(hour created_at)').count
ruby-on-rails postgresql ruby-on-rails-4 group chartkick
No comments:
Post a Comment