SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating a archive list

    I've got a datetime field in my database. Now I want to sort them by month, and year and display them as a list. However, it only sorts by month and not the year.

    Any solution to this?

    Heres the query I used:
    SELECT DATE_FORMAT(created, '%M %Y') AS posted FROM prod_info WHERE category = 'News' GROUP BY posted ORDER BY posted DESC
    End result should be:
    August 2009
    January 2009
    November 2008
    May 2008

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    try:

    ...ORDER BY created DESC

  3. #3
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha..I knew I'm missing something. Thanks a lot Cups!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •