蜂巢3.0.0想要将时间戳转换为带掩码的字符串

时间:2020-10-09 13:53:17

标签: hive timestamp hiveql to-char

我必须还原日期转换 一开始是

CAST(FROM_UNIXTIME(UNIX_TIMESTAMP(t0.date_creation , 'yyyyMMdd'T'hhmmss')) AS TIMESTAMP)

现在我正在研究如何将时间戳转换为'yyyyMMdd'T'hhmmss'格式

语法CAST(date_creation as string format 'yyyy-MM-dd hh:mm:ss')不起作用

1 个答案:

答案 0 :(得分:1)

使用date_format函数:

select current_timestamp, date_format(current_timestamp,"yyyyMMdd'T'HHmmss") as result;

返回:

2020-10-09 15:03:36.584       20201009T150336

在此处了解格式:SimpleDateFormat