How do I group by day instead of date?

前端 未结 6 1758
情书的邮戳
情书的邮戳 2020-12-03 13:56

ok so i have

 >> list = Request.find_all_by_artist(\"someBand\")
=> [#

        
6条回答
  •  长情又很酷
    2020-12-03 14:29

    There is a gem for that: groupdate.

    Usage (from the docs):

    User.group_by_day(:created_at).count
    # {
    #   2013-04-16 00:00:00 UTC => 50,
    #   2013-04-17 00:00:00 UTC => 100,
    #   2013-04-18 00:00:00 UTC => 34
    # }
    

提交回复
热议问题