Forum Moderators: coopster

Message Too Old, No Replies

MySQL / PHP dates

         

wendystewart80

3:47 pm on Feb 27, 2006 (gmt 0)

10+ Year Member



Hi There,
I am using php to call info from a mysql database. My date comes in format yyyy-mm-dd but I want it in dd-mm-yyyy. I know I need to use something like:
SELECT DATE FORMAT (date, %d-%m-%y)

But I'm not sure how to include it in my query which is also calling other items from the database:
$result1 = mysql_query("SELECT * FROM practice AS p, project AS t, regions AS r, gpcats AS c
WHERE p.id = t.id AND t.region = r.region AND p.gpid = c.gpid AND gptext LIKE '%$search%' AND $region=0 AND '$cat'='0'
GROUP BY p.gpid
ORDER BY verified DESC
"
Can anyone shed any light?
Thanks
Wendy

coopster

5:55 pm on Feb 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You just need to add it to your SELECT expression. If you are selecting all the fields, which is what your example shows, you just add this expression as well. Something like ...
SELECT *, DATE_FORMAT('2006-01-16', '%d-%m-%Y') AS dateFormatted FROM ...