Reputation: 1344
I'm working on an app that will allow users to search for any recordings we have in a database, organized by three values: agent (name), phone, and date. date is recorded as a datetime value. I want to provide advanced search features that will allow users to select time ranges following this guideline:
Year: entered into a text field Month: entered into a text field Day: entered into a text field Hours: two select lists representing a range upper and lower bound Minutes: two select lists representing a range upper and lower bound
I watched this Railscast for help on how to get started with the search logic, but I'm concerned because I don't know how to pass in dateparts into Rails queries. Normally you would run something like select date_part(hh, date) as date_hour from table_name
to get the value of hour, but how would you do that in Rails, or in the way Ryan Bates suggests in his Railscast?
Upvotes: 0
Views: 449
Reputation: 4070
You may concat the values in the controller accessing them by the params
and then parse to a datetime
Then DateTime.strptime allows you to specify the format and convert a String to a DateTime.
Upvotes: 1