Jump to content

ORDER by date DESC


piet

Recommended Posts

i have a little problem, i need to order a query by date.

but in the db, the date field is formulated "14.01.2008" instead of "2008.01.14"

 

so the result is my output is all scrambled.

 

i have alot of other scripts reading from this db so changing the field is not an option as it will mess up the other scripts.

 

is there somrthing in the php query that i can add to output that data corectly?

 

thanks

 

Piet

Link to comment
https://forums.phpfreaks.com/topic/85919-order-by-date-desc/
Share on other sites

Something like the code shown below would rearrange the date AFTER you have extracted all the rows from the db.

 

function rearrange($date) {
$parts=explode(".", $date);
$newdate=$date[3].".".$date[2].".".$date[1];
}

 

As for changing the way you query the db, I really think to make it simpler in the long run it's easier to change the column in the database, after all you can always call a common function from every other php file that needs the date to arrange the date in the way you normally use it.

Link to comment
https://forums.phpfreaks.com/topic/85919-order-by-date-desc/#findComment-438663
Share on other sites

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.