user1760765
user1760765

Reputation: 23

Selecting MySQL datetime in a range

I have seen at least 2 dozen questions just like this on StackOverflow but not a single one of the approved answers worked for me.

I am trying to run this MySQL query:

SELECT * FROM requests WHERE date_created between "2012-10-01 00:00:00" AND "2012-11-01 00:00:00"­

And the error that I'm getting is this:

#1064 - 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 '­ LIMIT 0, 30' at line 1

I do not understand this error! I am not even using "limit" in my query.

Any help would be greatly appreciated. Thank you.

Upvotes: 2

Views: 10262

Answers (2)

Elisée
Elisée

Reputation: 259

Without more context, I would say the error is probably referring to another query in your code which actually has a "LIMIT 0, 30" in it.

Upvotes: 0

Yogendra Singh
Yogendra Singh

Reputation: 34367

Try this :

 SELECT * FROM requests 
 WHERE date_created between DATE('2012-10-01 00:00:00') 
                            AND DATE('2012-11-01 00:00:00'­)

Upvotes: 4

Related Questions