|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Query output - based on date range
Ahhh,coldfusion.developer 03/20/07 01:34 P coldfusion.developer@att.net wrote:Jim Wright 03/20/07 02:01 P Ahhh, I have an events database that lists the details of an event and the date range of number days the event runs. If it's a one day event, eventdate is the same as eventdate2. I've got the events outputting over a calendar so all the events show a single listing of each event. I want to display the event in each day within the date range within a calendar. Should I be using cfloop instead? Any ideas would be so helpful. Thanks. OUTPUT CODE <cfoutput query="Events"> <tr> <td class="date_cell">#LSDateFormat(Events.EVENTDATE,'MMM')# <strong>#LSDateFormat(Events.EVENTDATE,'DD')#</strong></td> <td class="name_loc_cell">#Events.EVENTNAME#</td> <td class="name_loc_cell">#Events.EVENTLOCATION#</td> <td>#Events.EVENTDESCR#</td> </tr> </cfoutput> coldfusion.developer@att.net wrote: ----- Excess quoted text cut - see Original Post for more ----- For things like this, sometimes it can be good to have a utility table that lists the dates that you need to view...so just have a table something like... tblDates thisdate datetime populate that with every day from some way back date to some way forward date...then it makes it very easy to join against your events table and find all events within a date range and have them assigned to the correct date(s)... SELECT a.thisdate,b.eventname,b.eventlocation,b.eventdescr FROM tblDates a LEFT JOIN Events b ON a.thisdate >= b.eventdate AND a.thisdate <= b.eventdate2 WHERE (limit tblDates by some date range) ORDER BY a.thisdate,b.eventname Then you can just use cfoutput and group to output a calendar of events that shows all of the days in the range... <cfoutput query="Events" group="thisdate"> <h1>#thisdate#</h1> <ul> <cfoutput> <li>#eventname#<BR>#eventlocation#<BR>#eventdescr# </cfoutput> </ul> </cfoutput>
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||