Reputation:
This query was working before, but maybe I changed it somehow..
select * from completed_games where date BETWEEN 2015-02-22 00:00:00 AND 2015-02-28 00:00:00
Why would this query not work, and how can I properly write it?
Error:
ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '00:00:00 AND 2015-02-28 00:00:00' at line 1
Upvotes: 0
Views: 4738
Reputation: 58
If you don't need to check a time you can even do the following:
SELECT *
FROM completed_games
WHERE `date` BETWEEN '2015-02-22' AND '2015-02-28'
Tip: Try to use backticks (`) around keywords or special chars.
Upvotes: 1
Reputation: 219874
You need to put quotes around your date strings:
select *
from completed_games
where date BETWEEN '2015-02-22 00:00:00'
AND '2015-02-28 00:00:00'
Upvotes: 1
Reputation: 1180
Your dates are not valid. You need to enclose them between quotes.
select *
from completed_games
where date BETWEEN '2015-02-22 00:00:00' AND '2015-02-28 00:00:00'
Upvotes: 2