How to use greater than operator with date?

Clinton J picture Clinton J · Nov 19, 2012 · Viewed 279.7k times · Source

No idea what is going on here. Here is the query, right from phpMyAdmin:

SELECT * FROM `la_schedule` WHERE 'start_date' >'2012-11-18';

But I consistently get all records in the table returned, including those with start date 2012-11-01. What gives?

Answer

John Woo picture John Woo · Nov 19, 2012

you have enlosed start_date with single quote causing it to become string, use backtick instead

SELECT * FROM `la_schedule` WHERE `start_date` > '2012-11-18';