Solved

Looping and checking the previous row for a value in a loop?

Posted on 2006-06-16
2
166 Views
Last Modified: 2013-12-24
Hi,

I am trying to work with this recordset and cant recall how to do this.  Each record has a date, but when looping over the records if the date in the currentRow is equal to the date in the previous row, then don't show a date.  This should be very easy to do.  I just cant recall the correct syntax for doing so.

I have a query that I am looping over and each record has a "date" so:

DATE          STATE
04/10/06     CA
04/10/06     OR
04/15/06     FL
04/18/06     WY


If you notice above, the date 04/10/06 appears twice.  I only want the date to appear once if it is the same so it should be like:

DATE          STATE
04/10/06     CA
                  OR
04/15/06     FL
04/18/06     WY

There must be a way to take the currentRow's date value and then look at the previous row and if its the same, make it blank.

-ws
0
Comment
Question by:Westside2004
2 Comments
 
LVL 9

Accepted Solution

by:
73Spyder earned 175 total points
Comment Utility
Easiest way would be to set a temp variable

<cfset variables.temp_value = "">
<cfoutput query="your_data">
     <cfif your_data.date NEQ variables.temp_value >
             display date here
     </cfif>
   // - Rest of data here


<cfset variables.temp_value = your_data.date>
</cfoutput>

This should displat the date the first time it appears in the recordset but skip other rows
0
 
LVL 1

Author Comment

by:Westside2004
Comment Utility
Worked... thanks

-ws
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now