Alex Rivera | Logout

Mysql select query after certain date

Asked 2011-08-30T21:18:09.310
24

I am trying to pull records after a certain date using mysql query , the field type is date in my database and the query is

SELECT * FROM tickets WHERE created_on > 26-08-2011

But it is not working and also showing all before that date

Thanks

Edit
Report

1 Answer

62

The date you are using is a string, so it needs to be placed inside quotes. Also, the format is the wrong way around:

SELECT * FROM tickets WHERE created_on > '2011-08-26'

For more information, see the MySQL docs. In particular, note the very first line:

The format of a DATE value is 'YYYY-MM-DD'. According to standard SQL, no other format is permitted.

answered 2011-08-30T21:21:25.537

Your Answer