Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

MySQL str_to_date 如果字符串中没有年 怎么补上?

格式完整的字符串时间可以通过str_to_date转换为标准时间。
但是这种没有“年份”的数据,转换后年份为0000:
image.png
image.png

这种怎么在转换后,补上2020?

已解决:
select CONCAT(2020,RIGHT(str_to_date(chengjiao,'%m-%d'),6)) as sell_time,sell from table_name ORDER BY sell_time


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

已解决:
select CONCAT(2020,RIGHT(str_to_date(chengjiao,'%m-%d'),6)) as sell_time,sell from table_name ORDER BY sell_time


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...