Solved

Worked in Access, but not in MySQL

Posted on 2003-11-10
4
190 Views
Last Modified: 2013-12-24
Hi

Can anyone tell me why this worked using Access, but doesn't when using MySQL?

<cfset currentDate = CreateODBCDate(Now())>

<cfquery name="bulletinBoard" datasource="intranet2">
SELECT *
FROM MAIN
WHERE (CATEGORY = 'Bulletin Board' AND SUBMITTED >= #currentDate-90#)
ORDER BY SUBMITTED DESC, ID DESC</cfquery>

This is supposed to return all of the entries within the database from the Bulletin Board in the last 90 days.

Cheers
Nick
0
Comment
Question by:nelliott
[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
  • 3
4 Comments
 
LVL 11

Expert Comment

by:hart
ID: 9714011
try this
<cfset currentDate = CreateODBCDate(Now())>
<cfset submitteddate = dateadd('d',currentDate,-90)>

SELECT *
FROM MAIN
WHERE (CATEGORY = 'Bulletin Board' AND SUBMITTED >= #CreateOdbcDateTime(submitteddate)#)
ORDER BY SUBMITTED DESC, ID DESC


Regards
Hart

0
 
LVL 11

Accepted Solution

by:
hart earned 250 total points
ID: 9714038
much better way would be to use cfqueryparam

SELECT *
FROM MAIN
WHERE CATEGORY = <CFQUERYPARAM      CFSQLTYPE="cf_sql_varchar" VALUE="Bulletin Board">
            AND SUBMITTED >= <CFQUERYPARAM CFSQLTYPE="cf_sql_date" VALUE="#submitteddate#">
ORDER BY SUBMITTED DESC, ID DESC

Regards
Hart
0
 

Author Comment

by:nelliott
ID: 9714127
Thanks very much Hart.

Would you advise using cfqueryparam on every query?  
0
 
LVL 11

Expert Comment

by:hart
ID: 9714222
yes i would :-)

Regards
Hart
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

635 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