如何将这个字段的类型转换成日期格式?

显示目标表格的字段构成:

show create table target;
| target | CREATE TABLE target (
代码 text,
截止日期 text)
SELECT 截止日期 from target limit 10;
截止日期
2014/12
2015/12
2016/12
2017/12
2018/12
2015/06
2016/06
2017/06
2018/06
2019/06

10 rows in set (0.00 sec)

我如何将这个字段 “截止日期” 转换成日期类型?

阅读 1.7k
2 个回答

mysql有函数:

select str_to_date(截止日期, '%Y/%m') from target;
select code,STR_TO_DATE(endtime,'%Y/%m') endtime from target;

图片描述

推荐问题