Query output - based on date range

2007-03-20 Thread coldfusion . developer
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 MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV

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


Re: Query output - based on date range

2007-03-20 Thread Jim Wright
[EMAIL PROTECTED] wrote:
 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
 

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



~|
Macromedia ColdFusion MX7
Upgrade to MX7  experience time-saving features, more productivity.
http://www.adobe.com/products/coldfusion?sdid=RVJW

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