Skip to main content
Known Participant
June 9, 2010
Question

outputing news as nested list

  • June 9, 2010
  • 2 replies
  • 626 views

Hi,

I have a news section with dates saved as a mysql date. (2010-06-09)

What i would like to do us categorise them by year and month

2010

   january

    newsitem1

     newsitem2

february

    newsitem1

     newsitem2

2009

december

    newsitem1

     newsitem2

Is this possible just using date or will I have to add extra colums to my table (year and month?)

Thanks,

H.

    This topic has been closed for replies.

    2 replies

    Known Participant
    June 9, 2010

    i think you should be able to use cfoutput group by year, then month then item.  that would be easier than looping thru ...

    June 9, 2010

    It is possible to use the date variable directly, you do not have to seperate the date parts. Simply use the date and time functions from coldfusion:

    - DateFormat(yourDate)

    - Month(yourDate)

    - Year(yourDate)

    DateFormat, Month and Year are all standard cf-functions. Take a look at the livedocs (e.g. http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ff4.html)

    HulfyAuthor
    Known Participant
    June 9, 2010

    That's good to know. How about looping through. Would I have to put them in an array?