Andy:
        Maybe I'm missing your point, which is possible since the query you listed
and the query you are looping through don't appear to be the same queries.
I'm assuming that they are supposed to be.  In order to get the last date
pair to show just do thsi:
<cfoutput>#DateFormat(DatStartRange, 'm/d/yy')# - #DateFormat(DatEndRange,
'm/d/yy')#</cfoutput>

right after the </cfloop> you have listed.  I also think you can get rid of
the line that says <cfset datStartRange = EndDay> and move it to before the
loop.  Does this help?


Andrew Hewitt
Web Application Developer
webworld studios, inc.
www.wwstudios.com



-----Original Message-----
From: cf kaizen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 14, 2000 11:04 PM
To: CF-Talk
Subject: grouping date ranges


Hi,

I've got some query results that consist of a field
called startDate. In general, the values in this field
are successive, i.e. Jan 1, 2, 3, 4, 5, 15, 16, 17
etc. Let's say I've got 9 records in this recordset,
and the startDate looks like this:

Jan 1
Jan 2

Jan 4
Jan 5

Jan 8
Jan 9
Jan 10
Jan 11
Jan 12

I want to show those ranges together on the page, like
this:

1/1  to 1/2
1/4 to 1/5
1/8 to 1/12

The way I am doing this is to look for these date gaps
with the code below. Essentially startDate of the next
record does not equal the StartDate of this record +
1, set the range. However, the last range is not seen
because the code I use to check the data compares the
current record with the next, and it doesn't "see" the
final gap in the dates, because there is none.. Here
is the code (don't laugh). Any ideas on a better way?
Array? Structure? Thanks in advance for your help.
Andy

 <cfQuery name="getDates" datasource="#Source#">
 SELECT StartDate
</cfquery>
 <cfSet FirstDay = "#getDates.StartDate#">
 <cfset NewFirstDay = "#getDates.StartDate#">
 <cfset EndDay = "#getDates.StartDate#">
 <cfLoop query="checkavailabilityNonSetRoom">
   <CFOUTPUT>
   <cfif StartDate eq FirstDay>
       <cfSet datStartRange = EndDay>
       <cfSet datEndRange = StartDate>
       <cfSet FirstDay = DateAdd('d', 1, FirstDay)>
   <cfelse>
          <!--- I said don't laugh! --->
          #DateFormat(DatStartRange, 'm/d/yy')# -
#DateFormat(DatEndRange, 'm/d/yy')#</font><br>
         <cfset datStartRange = StartDate>
         <cfSet FirstDay = DateAdd('d', 1, StartDate)>
         <cfSet EndDay = StartDate>
    </cfif>
  </cfoutput>
</cfLoop>

The above code will give me 1/1  to 1/2 and 1/4 to
1/5, but not 1/8 to 1/12 because it "sees" no final
gap in the records. Again, any help is greatly
appreciated. - Andy

__________________________________________________
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
http://calendar.yahoo.com/
----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]


------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to