ruby on rails - Comparing a Date to the Datetime Created_at in rails3 -


so i'm trying things so:

today = date.today - 1 todaysreport = report.where(:created_at => today).find_by_user_id(user.id) 

the problem created_at datetime, won't find matches..any suggestions?

you want this:

yesterday = time.now - 1.day user = user.find(user_id)  todaysreport = user.reports.where(["created_at >= ? , created_at <= ?", yesterday.beginning_of_day, yesterday.end_of_day]) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -