Solved

MySQL Between Dates Problem...

Posted on 2010-09-07
3
344 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What's the best way to programatically have a MySQL DB update another MySQL DB 4 68
CREATE DATABASE 3 30
ASP exit 10 20
Reg Exp to extract Url from string asp 12 16
Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
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…

821 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