I am trying to fetch records on database on localhost.
My columns from & to are dateranges and I would like to convert daterange to date to find records.
date = Date.parse(2017-02-17)
sc = schedules.where("from <= ? AND to >= ?",date,date)
gives error;
SELECT "schedule_days".* FROM "schedule_days" WHERE "schedule_days"."car_id" = ? AND (from <= '2017-02-17' AND to >= '2017-02-17') [["car_id", 2]]
SQLite3::SQLException: near "from": syntax error: SELECT "schedule_days".* FROM "schedule_days" WHERE "schedule_days"."car_id" = ? AND (from <= '2017-02-17' AND to >= '2017-02-17')
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "from": syntax error: SELECT "schedule_days".* FROM "schedule_days" WHERE "schedule_days"."car_id" = ? AND (from <= '2017-02-17' AND to >= '2017-02-17')
Is this problem because from & to are datetime?. I also tried;
schedules.where("date(from) <= ? AND date(to) >= ?",date,date)
no luck. I will then push this code to heroku postgresql