Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with query / between 2 dates

Status
Not open for further replies.

aamaker

Programmer
Jan 20, 2002
222
US
I have an event search site and have a simple form (search from date 1 to date 2 with an optional keyword text field) and I thought it was working, but have discovered that in some cases it just returns ALL the events from the database.

Here is the MM DW8 select statement I am using... am I doing something wrong with either my quotes or the # symbols? Im lost as to what the problem is.

Code:
RS_Events.Source = "SELECT *  FROM tbl_events  WHERE eventdate BETWEEN #" + Replace(RS_Events__MMColParam2, "'", "''") + "# AND #" + Replace(RS_Events__MMColParam3, "'", "''") + "# And eventtitle like '%" + Replace(RS_Events__MMColParam4, "'", "''") + "%' or eventdetail like '%" + Replace(RS_Events__MMColParam4, "'", "''") + "%'"
 
I would look at the language set up of the host box. We have no end of problems with date formats from USA to UK

[Peace][Pipe]
 
Fixed it...

What I found was that I needed to wrap the later part of the select statement (...And eventtitle like...) in parenthesis.... now it works.

Someone here (tek-tips) reminded me a few weeks back that its necessary sometimes to separate mixed sql select statements like this...

Thanks for the reply/feedback Cheech.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top