Find All Rows For A Certain Day; Count Days Between Two Dates
Join the DZone community and get the full member experience.Join For Free
# Find all rows created on a certain day; Rails apparently has a built-in :db string format self.find(:all, :conditions => ["created_at >= ? AND created_at <= ?", day.beginning_of_day.to_s(:db), day.end_of_day.to_s(:db)]) # Find number of days between two dates def days_between_dates(first, last) (YMD(last) - YMD(first)) end def YMD(date) date.to_date.to_s.gsub("-", "").to_i end
Opinions expressed by DZone contributors are their own.