Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Worked in Access, but not in MySQL

Posted on 2003-11-10
4
Medium Priority
?
192 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 1000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

730 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