Jump to content

Date problem , ORDER BY


JohneeMac

Recommended Posts

Hi there, i am trying to display some news with the most recent date at the top

 

heres my SQL:

 

$sql = mysql_query("SELECT *,
   date_format(article_date, '%D %M, %Y') as article_date 
   FROM news_system
   ORDER BY article_date 
   ASC LIMIT 5");

 

It seems to mess up and have a random order of things.

 

Thx.

Link to comment
Share on other sites

[!--quoteo(post=335531:date=Jan 11 2006, 10:35 AM:name=JohneeMac)--][div class=\'quotetop\']QUOTE(JohneeMac @ Jan 11 2006, 10:35 AM) 335531[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Hi there, i am trying to display some news with the most recent date at the top

 

heres my SQL:

 

$sql = mysql_query("SELECT *,
   date_format(article_date, '%D %M, %Y') as article_date 
   FROM news_system
   ORDER BY article_date 
   ASC LIMIT 5");

 

It seems to mess up and have a random order of things.

 

Thx.

 

It most certainly will. The mysql engine sees the dates like this (12.10.2005 -> 12102005, 24.12.1856 -> 24121856) so 24121856 is definetly bigger then 12102005.

 

The date format should be arranged first by year, then by month and then date. Or maybe use TIMESTAMP() instead.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.