Find all rows for a certain day; Count days between two dates
# 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