08-27字符串转换为配置单元中的日期

7xzttuei  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(334)

我使用下面的代码将其转换为日期格式,但我的输出总是空的。

select from_unixtime(unix_timestamp(b.temp,'yyyyMMdd'), 'yyyyMMdd') as temp1
from 
([![enter image description here][1]][1]
select a.*, regexp_replace(a.ao_date,'-','') as temp
from clla_samp_base a
) b ;

非常感谢您的帮助!

dxpyg8gm

dxpyg8gm1#

2016-08-27 是iso日期格式,这是hive“按原样”接受的唯一日期格式。

hive> select cast ('2016-08-27' as date) as dt; 
OK
dt
2016-08-27

附笔
如果有一列包含此格式的值,则可以首先将列类型定义为date。

相关问题