问题描述
使用Ruby On Rails Console,是否可以查询数据库中的所有记录?
之类的东西
date = "january 5 2013" users = User.find(:all, :conditions => {:created_at => date})
推荐答案
您可以这样做:
date = Date.parse('january 5 2013') users = User.where(created_at: date.midnight..date.end_of_day)
其他推荐答案
尝试这个,
User.where("Date(updated_at) = ?", "2018-02-9")
其他推荐答案
您也可以做到
User.where("created_at::date = ?", "january 5 2013".to_date)
问题描述
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" users = User.find(:all, :conditions => {:created_at => date})
推荐答案
You can do it like this:
date = Date.parse('january 5 2013') users = User.where(created_at: date.midnight..date.end_of_day)
其他推荐答案
Try this,
User.where("Date(updated_at) = ?", "2018-02-9")
其他推荐答案
You can also do it like
User.where("created_at::date = ?", "january 5 2013".to_date)