[EMAIL PROTECTED] wrote:
Hi,

I have a row in mysql database called time and is just a simple timestamp column

When I echo it out

echo $row['time'];
echo $row['content'];

I get the following

2005-08-30 13:50.05 "this is the text content"

Now I am not worried about the time but I would like to know how to

(i) sort the returned rows in order (latest first)
(ii) be able to extract the individual parts of the date and display them in UK format (ddmmyyyy)

30.08.2005 this is the text from 30th of August
27.08.2005 this is the text from 27th of August
27.08.2005 this is the text from 23rd of August

thanks,
R.

Use ORDER BY to get sorted results <http://dev.mysql.com/doc/mysql/en/sorting-rows.html>. Use DATE_FORMAT() to get the date output you want <http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html>.

  SELECT DATE_FORMAT(time, '%e.%c.%Y') AS time, content
  FROM your_table
  WHERE <where conditions as needed>
  ORDER BY time DESC;

The '%e.%c.%Y' will give "3.1.2005" for the 3rd of January. Use '%d.%m.%Y' to get "03.01.2005" instead.

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to