> -----Original Message-----
> From: Nate Willard [mailto:[EMAIL PROTECTED]
> Sent: Sunday, January 13, 2008 1:40 AM
> To: CF-Talk
> Subject: Output a Query by Date DESC, with A month, Day header were
> applicaple.
> 
> I've been struggling with a desired output. I'm eager
> to hear everyone's thoughts and ideas on how to
> efficiently achieve my goal. Thanks...
> 
> I have a query that returns the following data:
> TITLE - dateTime
> 
> The results span past a month. I would like a way to
> output the results as follows

Ordering or grouping by date should give you that.  You can use CFOUTPUT's
built in support for grouping output (via the "group" attribute) to display
the information how you've described in nested CFOUTPUT's.

Without any sample code it's hard to be more helpful but something like
this:

<cfoutput query="YourQuery" group="dateTime">
#DateFormat(dateTime, "mmmm dd")#<br>
----<br>
        <cfoutput>
                #Title#<br>
        <cfoutput>
</cfoutput>

In essence the group attribute is a looping construct: it takes a column
name and loops over the values in it.  For each value, inside the NESTED
CFOUTPUT it loops over each line of the recordset with the same value - when
the grouped value changes it re-runs the outer CFOUTPUT and the process
starts over.

Your datetime information comes directly from the query so there's no
fussing with information for "blank dates" - if it's not in the query, it's
not in the output.

It's basically a shortcut for the following (pseudo-)code (this assumes your
"TITLE, dateTime" query):

CurDate = null
LOOP OVER RecordSet

        IF CurDate NEQ CurrentRow.dateTime
                CurDate = CurrentRow.dateTime
                Output header for dateTime
        /IF

        Output Title.

/LOOP

You can see that each row in the recordset is processed by the main body but
only when the dateTime changes is the header output.  (CFOUTPUT is actually
more complex that this in that it also eliminates duplicate rows of data.)

Of course you don't need to understand it completely to use it.  ;^)

Jim Davis


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:296492
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to