I have a MySQL query written in python that checks for date range. The command is like:
"""
SELECT <something>
FROM <a_table>
WHERE datekey BETWEEN (SELECT date_key
FROM `date_table` WHERE date={date_start})
AND (SELECT date_key
FROM `date_table` WHERE date={date_end})
""".format(date_start=date_start, date_end=date_end)
where date_start and date_end are variables for date strings like 2014-04-13
now when I execute this command, it seems like MySQL interpret the date string as an equation, thus returning Incorrect date value: '1997' for column 'date' at row 1
1997 = 2014 - 4 - 13
That's how I figured.
I want to pass the string in as a raw string but I've failed doing so (I tried using r'' and u'')
Is there a way to pass the variables in as string?
WHERE date='{date_start}'