snagcheol
snagcheol

Reputation: 61

what is the problem of this mysql query?

SELECT
    *
FROM
    table_temp
WHERE
    install_date < NOW()
AND install_date > DATE_FORMAT(2011 - 06 - 16, "%Y-%m-%d")

Upvotes: 0

Views: 46

Answers (2)

Nathan Romano
Nathan Romano

Reputation: 7106

The value 2011 - 06 - 16 needs to be wrapped up in quotes

Upvotes: 1

Naftali
Naftali

Reputation: 146360

The problem resides on theis line:

install_date > DATE_FORMAT(2011 - 06 - 16, "%Y-%m-%d")

The 1st variable should be a string of a date

For example:

SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');

Or in your case:

install_date > DATE_FORMAT('2011 - 06 - 16', "%Y-%m-%d")

See MySQL DOC

Upvotes: 2

Related Questions