[英]SQL - Convert BIGINT(20) to datetime datatype
In mysql workbench, I have an id column in my table with bigint as its data type:在 mysql 工作台中,我的表中有一个 id 列,其数据类型为 bigint:
id BIGINT(20)
This column holds the datetime as a bigint.此列将日期时间保存为 bigint。
To clarify more, the column holds a value such as:为了更清楚地说明,该列包含一个值,例如:
20190529230339
I need to convert it into a datetime data type to be presented as:我需要将其转换为日期时间数据类型以显示为:
2019-05-29 23:03:39
STR_TO_DATE will do the trick: STR_TO_DATE 可以解决问题:
SELECT CONVERT(STR_TO_DATE('20130101 1130','%Y%m%d %h%i'),DATETIME); SELECT CONVERT(STR_TO_DATE('20130101 1130','%Y%m%d %h%i'),DATETIME);
I used Convert instead of Cast我使用 Convert 而不是 Cast
2013-01-01 11:30:00 2013-01-01 11:30:00
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.