Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the format of a date field via a Select Statment?

Status
Not open for further replies.

229257

Programmer
Apr 23, 2002
54
GB
I am writing in PHP a select statement and storing the restults.

When i write the following query the web page works fine:

$result=@mysql_query("select dateadd, rec_id, filename from orders");

But when i want to change the format of the date as it appears on the page using the following statement, the page doesn't work and gives an error.

$result=@mysql_query("select DATE_FORMAT(dateadd, "%e %M %Y") as dateadd, rec_id, filename from orders");

this select statement does work if i login to MYSQL on the server.


is what i am doing ambiguous? am i making a silly mistake? is there a better way of doing this?
 
i think the problem are the quotes - change that line to:
$result=@mysql_query('select DATE_FORMAT(dateadd, "%e %M %Y") as dateadd, rec_id, filename from orders');
hope that helps
 
$result=@mysql_query("select DATE_FORMAT(dateadd, '%e %M %Y') as dateadd, rec_id, filename from orders");

Use single quotes around any quotable with a mysql query as it will not fail with multiple pairs.
***************************************
Party on, dudes!
[cannon]
 
Thanks thats great, worked first time with single quotes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top