Jump to content

Using STR_TO_DATE() to get US Date Format


websteve

Recommended Posts

I have this Insert statement that converts the US date to the MySQL standand date format:

 

$pur="INSERT INTO Purchasing(ID, Item, Description, Quantity, Price, Date, AMPM) VALUES ('$cust_id','$item_a','$description_a','$quantity1','$price1',STR_TO_DATE('$date', '$datefilter'),'$ampm')";

 

$datefilter = '%m/%d/%y'; and the $date variable is received from a HTML form and it works fine.

 

But now, I'm trying to figure out how to do it in reverse, such as if I was to Select the date from the database and display it on the screen in US format? I can't seem to find the correct function.

 

Any help would be appreciated.

 

Thanks!

Link to comment
Share on other sites

otuatail, That has nothing to do with the question and since you cannot use functions as default values for datetime data types, it's invalid as well.

 

If the column happened to be a TIMESTAMP data type, you could use default values that are a few of the mysql function names, but that is not what the OP is doing or asking about.

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.