I am running a SQL query which returns some orders each having a date. I want to check which orders were made on current date ?
I am able to do so by:
orders = Order.find_by_sql(query).reject {|o|
today = Time.now
end_of_today = Time.local(today.year, today.month, today.day, 23, 59, 59)
start_of_today = Time.local(today.year, today.month, today.day, 00,00,00 )
o.date > end_of_today
o.date < start_of_today
}.sort_by {|o|
o.delivery_date
}
'orders' contain all the orders which were made at any time Today.
Is there a simpler way of doing this in ruby ?