Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Order By

  1. #1
    Regular Coder
    Join Date
    Sep 2009
    Location
    Calgary, Alberta
    Posts
    241
    Thanks
    48
    Thanked 3 Times in 3 Posts

    Order By

    I current have this in my mysql statement

    Code:
    date_format(date, '%m/%d/%Y') as date  FROM members order by date DESC
    but since the new year it places all 2013 items at the end of the query.

    any help would be great how I can get it to show the 2013 stuff ahead of the 2012 and etc..

    Thanks


    Slayer.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You have aliased back to the original property name, so you are now doing string comparisons, not date comparisons. Either don't alias back to date giving it a different name, or order by members.date. Either should work.

  • Users who have thanked Fou-Lu for this post:

    SlayerACC (01-12-2013)

  • #3
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hai...
    Check this coding ...
    It's worked properly...
    SELECT post(datefield as date) AS date_format ORDER BY date_format DESC

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,730
    Thanks
    80
    Thanked 4,515 Times in 4,479 Posts
    Quote Originally Posted by ahamadhussain View Post
    Hai...
    Check this coding ...
    It's worked properly...
    SELECT post(datefield as date) AS date_format ORDER BY date_format DESC
    *** WRONG ANSWER ***

    There is no such function as POST( ) in MySQL.

    And in any case, the answer is irrelevant to the question asked.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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