Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张大桌子,里面有大约 500 万行。
桌子:
ID (bigint), TRANS_DATE (TEXT)
例子:
04/05/12 11:30 有些行会像2012/22/05 14:50
04/05/12 11:30
2012/22/05 14:50
我创建了一个Date需要设置的新列date = STR_TO_DATE(TRANS_DATE , "????")
Date
date = STR_TO_DATE(TRANS_DATE , "????")
我应该在STR_TO_DATE格式中添加什么以将其更改为正确的数据库日期格式?
STR_TO_DATE
你可以这样做:
date = STR_TO_DATE(TRANS_DATE , (case when len(trans_date) = 14 then '%d/%m/%y %h:%i' else '%y/%m/%d %h:%i' end) )