?
Solved

MySQL Between Dates Problem...

Posted on 2010-09-07
3
Medium Priority
?
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

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 29

Accepted Solution

by:
sammySeltzer earned 2000 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

762 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