Why don't you do it all at once? Something like:
<cfset StartDAte = "11/17/2003">
<cfset ToDate = "2/19/2003">
<cfset StartDAte = CreateDate(Year(StartDAte),Month(StartDAte),1)>
<cfset ToDAte = CreateDate(Year(ToDAte),Month(ToDAte),DaysInMonth(ToDate))>
<cfquery name="yyy" datasource="xxx">
Select field1,field2, month(somedate) as themonth
from sometable where somedate between
#StartDAte# and #toDate#
Order by Month(somedate)
</cfquery>
Now you can just group it by month in the cfoutput using the
group attribute
>What is a good way to loop over the months within a time period? For
>example, given a starting date of 11/17/2003 and an end date of 2/19/2003,
>I'd need to loop through Nov03, Dec03, Jan04, Feb04. Within the loop I'll
>be doing queries with a where clause like:
>
>WHERE somedate BETWEEN #month#/1/#year#
> AND #month#/#DaysInMonth("#month#/1/#year#")#/#year#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the mailserver that powers this list at
http://www.houseoffusion.com/banners/view.cfm?bannerid=17
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189862
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54