Hive中的时间戳转换
我想将以下字符串值转换为配置单元中的时间戳 2016-12-31T07:09:48.507Z-->2016-12-31 07:09:48.507 你能告诉我怎么做吗Hive中的时间戳转换,hive,hiveql,Hive,Hiveql,我想将以下字符串值转换为配置单元中的时间戳 2016-12-31T07:09:48.507Z-->2016-12-31 07:09:48.507 你能告诉我怎么做吗 谢谢。希望这能帮助您将字符串转换为datetimestamp SELECT from_unixtime(unix_timestamp(REGEXP_REPLACE('2016-12-31T07:09:48.507S', 'T', ' '), 'yyyy-MM-dd HH:mm:ss')) 由于有毫秒,unix\u时间戳将无法工作。
谢谢。希望这能帮助您将字符串转换为datetimestamp
SELECT from_unixtime(unix_timestamp(REGEXP_REPLACE('2016-12-31T07:09:48.507S', 'T', ' '), 'yyyy-MM-dd HH:mm:ss'))
由于有毫秒,unix\u时间戳将无法工作。我想你需要这个
SELECT CAST(REGEXP_REPLACE('2016-12-31T07:09:48.507S', 'T|S', ' ') as timestamp) AS formatted_timestamp;
输出
formatted_timestamp
2016-12-31 07:09:48.507
也看到这个答案:太好了。谢谢