I am having an issue using the date variable in the following MySQL statement. The date variable contains a string which represents a date.
personal = Event.find_by_sql ["SELECT *
FROM events
WHERE DATE(start) = ?
AND HOUR(start) = ?
AND user_id = ?;", date, hour, user]
The following is the resulting query which is run on the database.
SELECT *
FROM events
WHERE DATE(start) = ''2015-02-27''
AND HOUR(start) = 9
AND user_id = 123456789;
An extra set of quotes is added around the date string, which causes an error. Is there any way to get rid of the extra pair of quotes?