Jump to content

[SOLVED] ordering by date DESC is going by the first Number


jesushax

Recommended Posts

hi heres my sql

 

$PortSQL = mysql_query("SELECT * FROM tblPortfolio WHERE PortCurrent='0' ORDER BY PortDateAdded DESC") or die(mysql_error());

 

when i get my result the dates go like such

 

21/02/08

20/09/07

18/02/08 

17/01/08 

10/11/07

 

so its going 21,20,18,17,10

 

not by actual date, is this becuase my field type is not date?

 

Okay, change it back and try this

 

1. rename the current date field to olddate

2. create a new field called newdate

3. query this (update table to the table name)

UPDATE table SET newdate = STR_TO_DATE(olddate, '%d/%m/%Y');

4. check the values of newdate

 

Note always keep a backup

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.