Jump to content


Photo

Order by DATE after Formatting


  • Please log in to reply
3 replies to this topic

#1 jcstanley

jcstanley
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 22 October 2006 - 02:36 PM

Hi

I had 'order by date' working fine:
$query = "SELECT itemid, title, picture, date FROM news ORDER BY 'date' desc";


but i wanted to change the format of the date was displayed so i changed it to:
$query = "SELECT itemid, title, picture, DATE_FORMAT(date, '%d %M %y') AS date FROM news ORDER BY 'date' desc";

Now the date format is ok but it won't order by the date!

Any ideas

Thanks

#2 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 22 October 2006 - 03:27 PM

try
$query = "SELECT itemid, title, picture, DATE_FORMAT(date, '%d %M %y') AS date_f FROM news ORDER BY 'date' desc";


#3 jcstanley

jcstanley
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 22 October 2006 - 03:34 PM

It doesn't appear to work  :(

i get: Warning: mysql_result(): date not found in MySQL result index 2

and no are dates displayed.

#4 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 24 October 2006 - 05:04 AM

OK
your output new has index date_f (mean date formated)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users