Between MySQL datetime values?

dolan2go
dolan2go used Ask the Experts™
on
runTime  is datetime type.

SELECT * FROM User WHERE runTime BETWEEN 2011-05-16 03:01:00 AND 2011-05-16 03:01:00

Open in new window


Results in:

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 '02:59:00 AND 2011-05-16 03:01:00' at line 1

SELECT * FROM User WHERE runTime BETWEEN '2011-05-16 03:01:00' AND '2011-05-16 03:01:00'

Open in new window


Results in:

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 '' at line 1
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
are you sure you don't have some other quotes around?
how do you run the query?

Author

Commented:
Wow. That was easy for you.

Solution:
Cut n paste is not always a time saver.

Author

Commented:
A great answer to get right to the point.
Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial