I have got the date range from the ui as - approved_between"=>"2013-03-17 - 2013-03-18"
I need to split this approved_start_date="2013-03-17" and approved_end_date="2013-03-18"....I am hoping to use this to query in mysql as the date format in mysql is created_at: 2012-07-28 10:35:01.
What I'm doing is-:
approved = approved_between.split(" ")
approved_start_date = approved[0]
approved_end_date = approved[2]
Pretty sure this isn't the most optimum way to process it, any better suggestions out there like split string in a single line, and assign them directly to variable?
that should be
approved_start_date, approved_end_date = approved_between.split(" - ")
UPDATE: using the dates in mysql
MyModel.where('DATE(created_at) = ?', approved_start_date)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With