我有一列显示'%Y%m%d%H%i%s'(例如20150125145900)如何将其转换为两列,一列为“ymd”,另一列为“his”(例如2015/01 / 25和14:59:00)?
答案 0 :(得分:0)
select datetime[0] as
年,datetime[1] as
{小时{1}}
from (select split(from_unixtime(unix_timestamp('20150125145900','yyyyMMddhhmmss'),'yyyy-MM-dd HH:mm:ss'),' ') as datetime)e
答案 1 :(得分:0)
<强>蜂房强>
select ts[0] as year
,ts[1] as hour
from (select split(from_unixtime(unix_timestamp('20150125145900','yyyyMMddHHmmss')
,'yyyy-MM-dd HH:mm:ss'),' ') as ts
) t
+------------+----------+
| year | hour |
+------------+----------+
| 2015-01-25 | 14:59:00 |
+------------+----------+
<强>帕拉强>
select split_part(ts,' ',1) as year
,split_part(ts,' ',2) as hour
from (select from_unixtime(unix_timestamp('20150125145900','yyyyMMddHHmmss')
,'yyyy-MM-dd HH:mm:ss') as ts
) t
;
+------------+----------+
| year | hour |
+------------+----------+
| 2015-01-25 | 14:59:00 |
+------------+----------+