Skip to main content
Participant
November 3, 2008
Question

Showing unique dates with multiple events

  • November 3, 2008
  • 2 replies
  • 332 views
I have a series of calendar events that I'm pulling from a database, and each of them has an associated datestamp. Basically, I want to be able to compact the dates, so that each unique date is listed only once. I would like to present them in a format that looks something like this:

Nov. 23: Pumpkin Festival
Comic Book Convention
Nov. 24: Woodworker's Presentation
Gallery Showing
Engineering Conference
Nov. 26: Music Festival

Right now, each event has to have a date associated with it. Like so:

Nov. 23: Pumpkin Festival
Nov. 23: Comic Book Convention.

You can see, they're both on November 23rd.

I've attached the code I'm using to pull the database. It's pulling events within a 31-day time period. Also, I've got variables that break up the datestamp into individual parts, so I just need to figure out how to show each unique date only once.
    This topic has been closed for replies.

    2 replies

    Inspiring
    November 3, 2008
    > so that each unique date is listed only once

    One way is to use the "group" attribute of cfoutput. In your SELECT, add a calculated field that extracts the date only. Then ORDER BY that field and "group" by it in your cfoutput. Since it contains date/time values, you can use DateFormat() to display the dates in MMM dd format.

    select
    convert(datetime, convert(varchar, yourDateColumn, 112), 112) as SortDate,
    othercolumns ...

    from your_table
    order by SortDate, othercolumns
    Inspiring
    November 3, 2008
    select dstart, count(dstart)
    from somewhere
    where something
    group by dstart
    having count (dstart) > 1;