开发者

MySQL DATE_FORMAT reverse?

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜