0
Showing unique dates with multiple events
New Here
,
/t5/coldfusion-discussions/showing-unique-dates-with-multiple-events/td-p/145156
Nov 03, 2008
Nov 03, 2008
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/showing-unique-dates-with-multiple-events/m-p/145157#M13345
Nov 03, 2008
Nov 03, 2008
Copy link to clipboard
Copied
select dstart, count(dstart)
from somewhere
where something
group by dstart
having count (dstart) > 1;
from somewhere
where something
group by dstart
having count (dstart) > 1;
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
LATEST
/t5/coldfusion-discussions/showing-unique-dates-with-multiple-events/m-p/145158#M13346
Nov 03, 2008
Nov 03, 2008
Copy link to clipboard
Copied
> 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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

