How to query for all records created today (midnight UTC..Now)

created_at => (DateTime.now.at_beginning_of_day.utc..Time.now.utc)

I think, you can try for below line as well.

ModelName.all :condition => ["DATE(created_at) = DATE(?)", Time.now]

OR In Rails 3

Model.where "DATE(created_at) = DATE(?)", Time.now

Cheers!


I think time zone should be considered.

where(:created_at => Time.zone.now.beginning_of_day.utc..Time.zone.now.end_of_day.utc)

And Rails will change time to utc time automatically, so the following is also ok.

where(:created_at => Time.now.beginning_of_day..Time.now.end_of_day)