Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Console - Find where created at = certain day

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}) 
like image 366
Seth Avatar asked Jan 28 '14 15:01

Seth


2 Answers

You can do it like this:

date = Date.parse('january 5 2013') users = User.where(created_at: date.midnight..date.end_of_day) 
like image 77
Agis Avatar answered Sep 17 '22 19:09

Agis


Try this,

User.where("Date(updated_at) = ?", "2018-02-9") 
like image 26
Praveen Kumar Avatar answered Sep 19 '22 19:09

Praveen Kumar