Hello,

  I’ve been tasked to display, in a table dates from a database, but the 
difficulty is that whenever there are 2 or more in a row, a range should be 
displayed.  

The table now looks like this:

May 27, 2013
June 1, 2013
June 2, 2013    
June 3, 2013    
July 4, 2013    

It should look like this:
May 27, 2013 
June 1, 2013 - June 3, 2013
July 4, 2013

I tried to get it into a list, so I could display listFirst, List,Last, but I 
can’t find a way to compare the last record to the current record to get into 
a loop (if indeed, my loop is right)
Here’s the code:
<tbody>
  <cfoutput query="currentClosures">
  <cfset thisDate = #holidayDate#>
      <cfset lastDate = #thisDate#>
     <cfset rangeList = ValueList(currentClosures.holidayDate)>
                    <cfif DateDiff( "d", thisDate, lastDate) EQ 1>
                    <cfloop query="currentClosures"> 
                        <cfset rangeList = ListAppend(rangeList, #holidayDate#)>
                        <cfset showDate = ListFirst(rangeList)>
                        <cfset lastDate = DateAdd("d", -1, thisDate)>
                    </cfloop>
                     <cfelse>
                       <cfset showDate = #holidayDate#>
                  </cfif>
    <tr>
               <td class="left" scope="row">
      
             #showDate#
</td>

Thanks much,
Lewis

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:6057
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to