![]() |
![]() OCAU News - Wiki - QuickLinks - Pix - Sponsors |
|
|||||||
| Notices |
|
Sign up for a free OCAU account and this ad will go away! Search our forums with Google: |
![]() |
|
|
Thread Tools |
|
|
#1 | |
|
Member
Join Date: Sep 2006
Location: Sydney
Posts: 275
|
Hello,
I am trying to construct a SQL query for a MySQL database that selects certain fields but at the same time converts a datetime field into something more user friendly. So far I have this query that selects and converts the date; Code:
SELECT DATE_format(time_sent, '%M %e, %Y<br>%l:%i%p') as newdate FROM messages And this query which selects all the other information I want; Code:
SELECT from_username, subject, read, FROM messages WHERE to_username='$session->username' Code:
SELECT DATE_format(time_sent, '%M %e, %Y<br>%l:%i%p') as newdate, from_username, subject, read, FROM messages WHERE to_username='$session->username'] Quote:
DJel. Last edited by DJel; 10th January 2008 at 10:49 PM. |
|
|
|
|
| Join OCAU to remove this ad! |
|
|
#2 |
|
Member
Join Date: Oct 2004
Location: Singapore
Posts: 6,256
|
Why don't you just select it then format it in PHP.. It would be much easier.
|
|
|
|
|
|
#3 |
|
Member
Join Date: Sep 2003
Posts: 547
|
get rid of the , before the FROM
|
|
|
|
|
|
#4 | |
|
Member
Join Date: Sep 2006
Location: Sydney
Posts: 275
|
Quote:
Thanks for that, the comma was one problem and there was also another problem with some quote marks further on. Thanks for the help guys, DJel. |
|
|
|
|
|
|
#5 |
|
Member
Join Date: Mar 2005
Location: St. Lucia, Brisbane
Posts: 3,200
|
|
|
|
|
![]() |
| Bookmarks |
|
Sign up for a free OCAU account and this ad will go away! |
| Thread Tools | |
|
|