My blog posts have a created_at
datetime attribute.
How would I use Blog.find
to retrieve all blog posts created on a given day (say 1/1/2009) ignoring the time on that day they were created?
My blog posts have a created_at
datetime attribute.
How would I use Blog.find
to retrieve all blog posts created on a given day (say 1/1/2009) ignoring the time on that day they were created?
This should be pretty close.
d = DateTime.new(2009, 1, 1)
Blog.find(:all, :conditions => [ "created_at >= ? AND created_at < ?", d.beginning_of_day, d.tomorrow.beginning_of_day ])