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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfquery problem with dates

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
This works fine:
Code:
<cfquery name="getDocs" datasource="#GQSRADAR_DSN#">
	SELECT COUNT(*) AS doc_total, rdr_doctype_id, (SELECT DocType_TTL_TXT FROM gqx_radar_doctypes WHERE DocType_id = gqx_radar_main.rdr_doctype_id) AS doctype_name
	FROM GQX_RADAR_MAIN
	GROUP BY rdr_doctype_id
	ORDER BY rdr_doctype_id
</cfquery>

This generates an error:
Code:
<cfquery name="getDocs" datasource="#GQSRADAR_DSN#">
	SELECT COUNT(*) AS doc_total, rdr_doctype_id, (SELECT DocType_TTL_TXT FROM gqx_radar_doctypes WHERE DocType_id = gqx_radar_main.rdr_doctype_id) AS doctype_name
	FROM GQX_RADAR_MAIN
	WHERE rdr_recv_dt >= '01/01/2000' AND rdr_recv_dt <= '09/01/2007'
        GROUP BY rdr_doctype_id
	ORDER BY rdr_doctype_id
</cfquery>
The error is: ODBC Error Code = 22005 (Error in assignment)
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

...and it points to the query as the culprit.

It's an Access DB. Any ideas?

Thanks!
 
Try this
Code:
<cfquery name="getDocs" datasource="#GQSRADAR_DSN#">
    SELECT COUNT(*) AS doc_total, rdr_doctype_id, (SELECT DocType_TTL_TXT FROM gqx_radar_doctypes WHERE DocType_id = gqx_radar_main.rdr_doctype_id) AS doctype_name
    FROM GQX_RADAR_MAIN
    WHERE rdr_recv_dt >=<cfqueryparam cfsqltype="CF_SQL_DATE" value="01/01/2000"> AND rdr_recv_dt <= <cfqueryparam cfsqltype="CF_SQL_DATE" value="09/01/2007">
        GROUP BY rdr_doctype_id
    ORDER BY rdr_doctype_id
</cfquery>

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Thanks Lyndon,

I posted a reply to this yesterday but it didn't get saved. Your solution worked. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top