Rails Console - Find where created at = certain day

后端 未结 5 600
醉话见心
醉话见心 2021-02-01 03:48

With Ruby on Rails console, is it possible to query the database for all records created on a certain day?

something like

date = \"january 5 2013\"
user         


        
5条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 04:29

    You can do it like this:

    date = Date.parse('january 5 2013')
    users = User.where(created_at: date.midnight..date.end_of_day)
    

提交回复
热议问题