I want to get all the records from the database which are create_at today. But when I do
Model.where('DATE(created_at) = ?',Date.today)
it returns only the last record that is created today. I have 3 records with created_at
2015-03-03 11:38:31
2015-03-03 11:59:00
2015-03-03 11:33:04
. But it returns only the record with '2015-03-03 11:38:31' this created_at date.
Also referred How to delete all records created today?, Getting all rows created today. I want to know why is this happening? Also tried
Model.where("DATE(created_at) = ?",Date.today)
and
Tracking::TrackingLogin.where("created_at >= ?", Time.zone.now.beginning_of_day)
Please someone explain what is happening in my code?