Solved

MySQL Between Dates Problem...

Posted on 2010-09-07
3
328 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now