Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save agungyuliaji/4662642 to your computer and use it in GitHub Desktop.
Save agungyuliaji/4662642 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