Tally List : mailing list management, archiving, and analysis
click for archive home
 
Archive of:
Fusebox
Cold Fusion Fuse Box List
 
home
24 hour view
quick stats
weekly updates
 
all tallylists
corporate solutions
archive your favorite
help / feedback


Search the Tallylist search by keyword:

About CF Fusebox Methods :
product's home
product's list home
 
  Archived TallyList / Fusebox: 
Subject: Looping Nightmare!
Greg Luce (2p/+0r)     Posted: Tuesday 17 Apr 2001
This post: 54 views, +0 rating

If anyone can take a peek at this and see what's wrong. I'm trying to fetch employment history records from 2 different queries, then display them. And then the tricky part, if there is a gap of 3 months or more after the last record (and not "to present") or between 2 employment records, show that. These are the results I'm getting right now, but they are wrong. There should be a gap between the second and third records, and the one between 3 and 4 should display "Gap In Employment", not the variable name. :-) I have a little trouble with the evaluate() function. Thanks for any insight. 5 0 34 57 Gap In Employment 1. 11/01/2000 - 11/01/2000 2. 02/01/1998 - 11/01/2000 3. 03/01/1994 - 04/01/1995 gap3 4. 05/01/1989 - 06/01/1989

Here's the code:

<!--- This code pulls a Members "to present" employment records first. --->

<cfset empcount = 1>

<Cfquery name="qGetPresentEmployment" Datasource="aeps" dbtype="#request.dbtype#" dbserver="#request.dbserver#"> SELECT * from employment where membernumber=#client.bgworkingon# and todate = '01/01/1900' order by fromdate DESC </cfquery> <cfif qgetpresentemployment.recordcount gt 0><!--- If there are "To Present" records. ---> <cfloop query="qgetpresentemployment"><!--- Loop thru the records setting variables for gap-comparison. ---> <cfoutput> <cfset "employer#empcount#fromdate" = #fromdate#> <cfset "employer#empcount#todate" = #todate#> <cfset empcount = empcount + 1><!--- Increment "empcount" ---> </cfoutput> </cfloop> </cfif> <!--- Next we pull the rest of the employment records that are NOT "To Present". ---> <Cfquery name="qGetEmployment" Datasource="aeps" dbtype="#request.dbtype#" dbserver="#request.dbserver#"> SELECT * from employment where membernumber=#client.bgworkingon# and todate <> '01/01/1900' order by todate DESC </cfquery> <cfif qgetemployment.recordcount gt 0> <!--- If there are employment records that're NOT "To Present". ---> <cfloop query="qgetemployment"> <!--- Loop throught them setting variables for gap-comparison. ---> <cfoutput> <cfset "employer#empcount#fromdate" = #fromdate#> <cfset "employer#empcount#todate" = #todate#> <cfif empcount gt 1> <!--- If there were "To Present" records, or it's NOT the first time through this loop. ---> <cfset x = empcount - 1> <!--- Set x = to the previous record's empcount ---> <cfset comparefrom = "#evaluate("employer#evaluate("x")#fromdate")#"> <!--- Set "comparefrom = previous record's "fromdate". ---> <cfelse> <!--- If there aren't "To Present records and this is our first time through this loop.---> <cfset comparefrom = "#now()#"> </cfif> <!--- Display Comparison of dates to see if there was a gap in employment. (Just for testing) ---> #datediff("m", evaluate("todate"), evaluate("comparefrom"))#<br> <!--- compare todate with either today's date or the previous record's "fromdate to see if there was a gap in employment greater than 3 months. ---> <cfif datediff("m", #todate#, #comparefrom#) gt 3> <cfset "gap#empcount#" = "Gap In Employment"><!--- Set a unique "Gap" variable if applicable. ---> <cfelse> <cfset "gap#empcount#" = ""> </cfif>

<cfset empcount = empcount + 1> </cfoutput> </cfloop> </cfif> <!--- End "fetching" loop. --->

<cfoutput> <!--- Loop through all "fetched" employment records. ---> <cfset tocount = qgetpresentemployment.recordcount+qgetemployment.recordcount> <cfloop index="currentrow" from="1" to="#tocount#"> <!--- If it's the first record to display and it was calculated earlier that there's a gap in employment, display it. ---> <cfif currentrow eq 1 and len(evaluate("gap#currentrow#")) gt 1> #evaluate("gap#currentrow#")#<br> </cfif> <cfset fromdate = "#evaluate("employer#evaluate("currentrow")#fromdate")#"> <cfset todate = "#evaluate("employer#evaluate("currentrow")#todate")#"> <!--- Display the rownumber, the fromdate, and the todate. ---> #currentrow#. #dateformat(fromdate, "mm/dd/yyyy")# - #dateformat(todate, "mm/dd/yyyy")#<br> <!--- If it's not a "to present" record, and it's not the last record in the list. ---> <cfif currentrow gt qgetpresentemployment.recordcount and currentrow lt tocount> <!--- If it was calculated earlier that there's a "gap" for this record, display it. ---> <cfif currentrow gt 1 and len(evaluate("gap#currentrow#")) gt 0> #trim("gap#currentrow#")#<br> </cfif> </cfif> </cfloop> </cfoutput><cfabort>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/fusebox@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists


Similar Subject Line Posts (+/- two weeks of this post)
Re: Looping Nightmare!  19 Apr 2001   (132 v/ +0 r)
RE: Looping Nightmare!  17 Apr 2001   (61 v/ +0 r)
Looping Nightmare!  17 Apr 2001 (this post)   (54 v/ +0 r)
 

Send a reply to the Fusebox list!
click to send a reply! NOTE: Many lists will reject your post unless you have already registered with them. Also - don't forget the right account to send from (for those with multiple emails!)

Feedback: If this post was exceptionally helpful, please help by giving this post a positive review.

 

TallyList : copyright Ububik - 2000