Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Showing unique dates with multiple events

New Here ,
Nov 03, 2008 Nov 03, 2008
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.
300
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 03, 2008 Nov 03, 2008
select dstart, count(dstart)
from somewhere
where something
group by dstart
having count (dstart) > 1;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 03, 2008 Nov 03, 2008
LATEST
> 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources