I am using MySQL DATE_FORMAT function to grab the date in the format i need it in. as the following:
SELECT DATE_FORMAT(`dob`, '%m-%d-%Y' ) as dob FROM `tblUsersProfile` WHERE `user_id` = 1
But now i want to update the开发者_Python百科 date from this format to the default mysql date format?
I know how to do this in php, but iam trying to change the format in MySQL. Anyone know?
You want MySQL's STR_TO_DATE()
function:
UPDATE tblUsersProfile SET `dob` = STR_TO_DATE('1-2-2011', '%m-%d-%Y') WHERE user_id = 1;
精彩评论