Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-12-2013, 05:52 PM   PM User | #1
SlayerACC
Regular Coder

 
Join Date: Sep 2009
Location: Calgary, Alberta
Posts: 222
Thanks: 45
Thanked 3 Times in 3 Posts
SlayerACC is an unknown quantity at this point
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.
SlayerACC is offline   Reply With Quote
Old 01-12-2013, 06:42 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
SlayerACC (01-12-2013)
Old 01-17-2013, 02:45 PM   PM User | #3
ahamadhussain
New to the CF scene

 
Join Date: Jan 2013
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
ahamadhussain is an unknown quantity at this point
Hai...
Check this coding ...
It's worked properly...
SELECT post(datefield as date) AS date_format ORDER BY date_format DESC
ahamadhussain is offline   Reply With Quote
Old 01-17-2013, 08:55 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,578
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:40 AM.


Advertisement
Log in to turn off these ads.