简体   繁体   中英

MySQL convert Varchar to DateTime

Trying to convert MySQL varchar field in this format

"07/25/2002 16:15" 

to correct MySQL datetime format

I tried the many variations of the STR_TO_DATE but still getting "Incorrect datetime value" errors.

我认为应该这样做:

STR_TO_DATE(colname, '%m/%d/%Y %H:%i')

SELECT STR_TO_DATE('07/25/2002 16:15','%m/%d/%Y %H:%i');

回报

2002-07-25 16:15:00

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM