Hi! I think that ColdFusion server does not have the Month function implemented in it's SQL processor (because the query get's processed by CF and never goes to your database server). When you put the pound signs around Month then CF treats it like a function and evaluates it's result once before he sends the resulted text to the SQL processing part.
One solution will be that you go throught the query by hand (with query_name.query_field[Row]) and construct the result query. Mack. ----- Original Message ----- From: "Tim" <[EMAIL PROTECTED]> Newsgroups: cf-talk Sent: Wednesday, February 20, 2002 11:48 AM Subject: Query a query by months > I am trying to query a query and process the records > by month. My code is: > > <cfloop index="cnt" to="12" from="1"> > <cfset QAvg = 0><cfset QAvgFinal = 0><cfset AvgCnt = > 0><cfset tcnt = 0> > <cfquery name="qGetRecords" dbtype="query"> > SELECT * > FROM qGetResults > WHERE (Month(qGetResults.Rundate) = #cnt#) > </cfquery> > <cfloop query="qGetRecords"> > <cfinclude template="GetClassPlacement.cfm"> > </cfloop> > > My problems are with the WHERE statement. If I do > WHERE #Month(qGetResults.RunDate)# = #cnt#, it > interprets the data as a variable (1 = 1, 1 = 2, etc) > and retirns all records when true (1 = 1). If I leave > the pound signs off, I get errors. > ______________________________________________________________________ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists