Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scratchoo/d9f8ed6916fe26fca7e02c2d1653166b to your computer and use it in GitHub Desktop.
Save scratchoo/d9f8ed6916fe26fca7e02c2d1653166b to your computer and use it in GitHub Desktop.
ActiveRecord Find By Year, Day or Month on a Date field
Model.where(:date_column => date)
Model.where('extract(year from date_column) = ?', desired_year)
Model.where('extract(month from date_column) = ?', desired_month)
Model.where('extract(day from date_column) = ?', desired_day_of_month)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment