Jump to content

[RESOLVED] need date format assistance


drranch

Recommended Posts

I have three date fields I need to display on my mysql query results page and I can't seem to find how to display them in the %M%d%Y format rather than the mysql format of yyyy-mm-dd
here is my query....I also want to pull all other fields from this table as well.

$query_rscars = sprintf("SELECT * FROM cars WHERE name = '$carlist'", $name_rscars,$name_rscars);

I've read its best done with the mysql script and not the PHP script.

Link to comment
Share on other sites

Okkkkkk  I figured this out ;D

query reads...(red is the code I needed assistance with)
$query_rscars = sprintf("SELECT *, [color=red]DATE_FORMAT(purchase_date, "%%b %%d %%Y") AS fpurchasedate, DATE_FORMAT(sell_date, "%%b %%d %%Y") AS fselldate, DATE_FORMAT(service_date, "%%b %%d %%Y") AS fservicedate[/color]  FROM cars WHERE name = '$carlist', $name_rscars, $name_rscars");

HTML results page reads.....

<?php echo $row_rscars['fpurchasedate']; ?>
<?php echo $row_rscars['fselldate']; ?>
<?php echo $row_rscars['fservicedate']; ?>

Web page view....
purchase date:  Aug 22, 2005
sell date: Aug 5, 2006
servicedate: Jul 17, 2006
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.