Last active
September 12, 2023 00:13
-
-
Save agungyuliaji/4662642 to your computer and use it in GitHub Desktop.
ActiveRecord Find By Year, Day or Month on a Date field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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