How to convert date fromat for mysql?

Posted by Shubham under ASP.NET on 12/31/2012 | Points: 10 | Views : 1292 | Status : [Member] | Replies : 3
Hi>>>
i want to convert date format for mysql ..
because i have a textbox which contains a date like 23/12/2012
and i want to convert to mysql date format like 2012-12-23
how to do this????
thanks in adv....

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar



Responses

Posted by: Baimey on: 12/31/2012 [Member] Starter | Points: 25

Up
0
Down
SELECT date_format(mydatefield,'%m/%d/%Y') as mydatefield FROM mytable

Please Mark as Answer If this Helps

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Baimey on: 12/31/2012 [Member] Starter | Points: 25

Up
0
Down
Do you want ot convert format while saving to MySQL

Then,
This is another function u can use
mysql_query("UPDATE `Table` SET `date` = STR_TO_DATE(`date`, '%d-%m-%Y')");

Please Mark as Answer If this Helps

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Baimey on: 12/31/2012 [Member] Starter | Points: 25

Up
0
Down
Please check the below link for more info
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format

Please Mark as Answer If this Helps

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response