First, use CFQUERYPARAM it can get you around problems with quotes.
Second, use createODBCdate(function) to turn your date into something that
the database will definitely recognize.
Note: in some versions of CF, there was a bug in CFQUERYPARM so that it
doesn't like to CF process functions inline so I always use the functions
before issuing the query:
The following should work:
<cfset thedate = createODBCDate("5/10/2004")>
<cfquery ...>
SELECT class_enrollment
FROM tbl_class_enrollment
WHERE class_id = 840 AND section = '07409'
AND enrollment_date = <cfqueryparam cfsqltype="CF_SQL_DATE"
value="#theDate#">
</cfquery>
-----Original Message-----
From: Austin Govella [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 13, 2004 3:15 PM
To: CF-Talk
Subject: Trouble filtering query based on date
I'm trying to query a specific record based on the date.
I've tried two variations on the same query: one places
quotes round the date, and the other does not (the date is a
date/time field in an Access database).
I am getting this error: "Too few parameters. Expected 1."
Here are the queries in question.
SELECT class_enrollment
FROM tbl_class_enrollment
WHERE class_id = 840 AND section = '07409'
AND enrollment_date = 5/10/2004
SELECT class_enrollment
FROM tbl_class_enrollment
WHERE class_id = 840 AND section = '07409'
AND enrollment_date = '5/10/2004'
I've been working on this off and on for a couple of days
and I don't understand what's wrong. Any tips or pointers as
to *why* this isn't working would be greatly appreciated.
Online tutorials don't devote much time to date/time formats.
Thanks,
--
Austin
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

