Skip to content

Instantly share code, notes, and snippets.

@delba
Created July 17, 2013 17:43
Show Gist options
  • Select an option

  • Save delba/6022745 to your computer and use it in GitHub Desktop.

Select an option

Save delba/6022745 to your computer and use it in GitHub Desktop.
date in ActiveRecord
scope :today, ->{ where('DATE(created_at) = ?', Date.today } # MySQL
scope :today, ->{ where('created_at::date = ?', Date.today } # PostgreSQL
Item.where(created_at: 5.days.ago..Date.today)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment