How do I find all the datetimes that happen on a particular date in ruby?
Posted
by Angela
on Stack Overflow
See other posts from Stack Overflow
or by Angela
Published on 2010-05-19T04:38:04Z
Indexed on
2010/05/19
4:40 UTC
Read the original article
Hit count: 176
dates
I have a method which goes through each day of the week:
def dates_week(d, delim)
"<tr>" + (d.beginning_of_week...(d.beginning_of_week+5)).map do |day|
"<#{delim}> #{yield(day)} </#{delim}>"
end.join + "</tr>"
end
For each day of the week, I plug that as an arg into a method (or maybe a named_scope, haven't figured out which), that will then output the .count for :all the emails that have a :date_sent on that date. However, :date_sent is a date-timestamp, so I can't use == as I have below.
def sent_emails_by_date(date)
ContactEmail.find(:all, :conditions => "date_sent = '#{date}'"
" ).count
end
How do I find all the emails that fall on the day for the date passed through from the method which loops through a week as shown above?
© Stack Overflow or respective owner