Skip to main content
Inspiring
May 21, 2008
Question

How to group by year

  • May 21, 2008
  • 2 replies
  • 796 views
Hi,
I have the following simple query:
SELECT pubdate, title
FROM table
ORDER BY date DESC

Which returns hundreds of records. Instead of outputing every single date within a year for pubdate, I would like to group the output based on the year. So the display would like something like:

2008
2007
2006
...
1970 etc.
How can I output this?
    This topic has been closed for replies.

    2 replies

    jenn1Author
    Inspiring
    May 21, 2008
    You rock! That is exactly what I was looking for. Thank you.
    Inspiring
    May 21, 2008
    jenn wrote:

    > How can I output this?
    >

    With the <cfoutput...> tag.

    Ok a little more information.

    <cfoutput query="simpleQuery" group="date">
    #date#
    <cfoutput>
    #title#
    </cfoutput>
    <br/>
    </cfoutput>

    jenn1Author
    Inspiring
    May 21, 2008
    But this displays all the dates within a year. I just want to display the #DatePart("yyyy", date# to get
    2008, 2007 etc. and not 5/21/08, 5/21/08....1/1/1979.
    jenn1Author
    Inspiring
    May 21, 2008
    I would like to group the output by year.