Page 1 of 1

Order by date

Posted: Wed Mar 10, 2004 9:13 am
by george3380
Hey all php newbie here. I'm trying to order a query by a date field. I've read around and it looks like the correct sql formatting is YYYY-MM-DD, however my current date format is DD.MM.YY

I've tried the following and it is not sorting correctly (I'm guessing because of the date format):

"SELECT * FROM tbl_hq_press_releases ORDER BY pr_dateAdded DESC";

What is the easiest way to format pr_dateAdded in this statement? I've been browsing the forums and a lot of people are using a DATE_FORMAT() function, but that seems to be undocumented by php.net.

Thanks for the help.

Re: Order by date

Posted: Wed Mar 10, 2004 9:23 am
by JayBird
george3380 wrote:
What is the easiest way to format pr_dateAdded in this statement? I've been browsing the forums and a lot of people are using a DATE_FORMAT() function, but that seems to be undocumented by php.net.
you need to look at the MySQL manual, not the PHP one

http://www.mysql.com

Mark

Posted: Wed Mar 10, 2004 1:29 pm
by Weirdan
Also store your date as dates, not the text. Read mysql manual data types section.