Just create 2 separate queries with cfif tags around them.  It means you will 
have 2 separate queries but its easier to understand.

 

e.g.

 

<cfif date is last month>

                <cfquery name-"blah" cachewithin ...>

 

                </cfquery>

<cfelse>

                <!--- this month query -à

                <cfquery name-"blah" cachewithin ...>

 

                </cfquery>

 

</cfif>

 

 

Thanks

 

Brian Knott

 

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of AJ Mercer
Sent: Tuesday, 8 April 2008 11:26 AM
To: [email protected]
Subject: [cfaussie] CF702 - cfquery caching

 

Hi Fusioneers,

I have an SQL I would like to cache, but have two strategies depending on the 
parameters

If the parameters are for the current month, I only want to cache the query for 
1 day
If it is for a past month, I want to start the caching from after the last day 
of that month

cfquery has two attributes to do this
    - cachedwithin
    - cachedafter

So I thought I would do this, but it looks like CF does not like the CFIF 
inside the cfquery tag
    <cfset rptDate = CreateDate(URL.year, URL.month, DaysInMonth(Now())) />

    <cfquery name="qryStatsByMonth" 
                 datasource="#APPLICATION.DataSourceMain#" 
                <cfif DateDiff('m', rptDate, Now()) EQ 0> 
                      cachedwithin="#CreateTimeSpan(1,0,0,0)#" 
                <cfelse> 
                       cachedafter="#rptDate#" 
                </cfif> 
     >

Any ideas how I can do this?

For now, I will put the cfif on the outside and have two cfqueries.
Guess this is not a bad way of doing it, just thought it would be neat if it 
could be done with one query.

-- 

AJ Mercer
Web Log: http://webonix.net


-----------------------------------------------------------------------------------
This e-mail is sent by Suncorp-Metway Limited ABN 66 010 831 722 or one of its 
related entities "Suncorp". 

Suncorp may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on 13 11 
55  or at suncorp.com.au.

The content of this e-mail is the view of the sender or stated author and does 
not necessarily reflect the view of Suncorp. The content, including 
attachments, is a confidential communication between Suncorp and the intended 
recipient. If you are not the intended recipient, any use, interference with, 
disclosure or copying of this e-mail, including attachments, is unauthorised 
and expressly prohibited. If you have received this e-mail in error please 
contact the sender immediately and delete the e-mail and any attachments from 
your system.

If this e-mail constitutes a commercial message of a type that you no longer 
wish to receive please reply to this e-mail by typing Unsubscribe in the 
subject line.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to