Advertisement

10.11.2008 at 08:38PM PDT, ID: 23807295 | Points: 500
[x]
Attachment Details

How can I setup a MySQL query between 2 user defined dates?

Asked by CheeserTheAverage in PHP and Databases

Tags:

I have a database that stores information in a table that includes a MySQL timestamp.  I want to run a MySQL query using PHP to pull all of the entries between two dates, but I can't figure out the syntax.

The MySQL timestamps are in the format of:    yyyy-mm-dd hh:mm:ss

I get the following error when I run the query:
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 invoiceDate < 2008-12-31 00:00:00'


Start Free Trial
1:
2:
3:
$invStartDate = "2007-01-01 00:00:00";
$invEndDate = "2008-12-31 00:00:00";
SELECT * FROM invoices WHERE invoiceDate > $invStartDate AND invoiceDate < $invEndDate
[+][-]10.11.2008 at 09:42PM PDT, ID: 22696344

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2008 at 12:31PM PST, ID: 22971871

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628