I am executing a ruby query:
Timeslot.where("start_date >= ? AND end_date <= ?", Wed, 01 Jul 2015 18:00:00 SGT +08:00, Wed, 01 Jul 2015 21:00:00 SGT +08:00)
I am getting the following error
SyntaxError: unexpected tCONSTANT, expecting ')'
...AND end_date <= ?", Wed, 01 Jul 2015 18:00:00 SGT +08:00, We...
I suppose it is because I am not escaping the ',' character after Wed. I have two questions:
1) How can I correct this query? 2) I will be replacing Wed, 01 Jul 2015 18:00:00 SGT +08:00 with an actual datetime variable? How can I type this query in the right way if the datetime were variables and not constants?
start_time= Time.nowandend_time = Time.now + 2.hours. Query:Timeslot.where("start_date >= ? AND end_date <= ?", start_time, end_time)Wed, 01 Jul 2015 18:00:00 SGT +08:00is neither a valid Ruby date, nor a valid SQL date.Date.todayin IRB (or rails console) returns a date that is formatted asMon, 13 Jul 2015, but enteringMon, 13 Jul 2015results in a syntax error.