Solved

MySQL Between Dates Problem...

Posted on 2010-09-07
3
340 Views
Last Modified: 2012-05-10
Hey Guys and Gals,
I am having an issue with an SQL string.  I am trying to pull some results from my MySQL database that will be between a set of dates given by the user.

I have attached my SQL string...

Also, the date field in my MySQL DB is a DATE field, not a DATETIME.

Any help would be appreciated!
"SELECT cancelStatus, orderDate, delTelephone, invTelephone, orderDate, invName, emailaddress, ordertotal, ocCusEmail FROM malsinfo WHERE ocCusEmail = '" & sessionName & "' AND orderDate BETWEEN  = " & startDate & " AND " & endDate & ""

Open in new window

0
Comment
Question by:Slim81
  • 2
3 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 33621194
It looks like you are missing ' (single quotes)

 "SELECT cancelStatus, orderDate, delTelephone, invTelephone, orderDate, invName, emailaddress, ordertotal, ocCusEmail FROM malsinfo WHERE ocCusEmail = '" & sessionName & "' AND orderDate BETWEEN  = '" & startDate & "'  AND  '" & endDate & "' " 
0
 
LVL 4

Author Comment

by:Slim81
ID: 33621788
Thanks for the advice sammy, I actually started with the single quotes but removed them to see if that was the problem.

I am still getting the same 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 '= '2010-09-01' AND '2010-09-07'' at line 1
0
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 33623815
hi Slim81

The error is correct because there is a "=" near between. Please remove it.

It should be this:

"SELECT cancelStatus, orderDate, delTelephone, invTelephone, orderDate, invName, emailaddress, ordertotal, ocCusEmail FROM malsinfo WHERE ocCusEmail = '" & sessionName & "' AND orderDate BETWEEN  '" & startDate & "'  AND  '" & endDate & "' "
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question