Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hive中的时间戳转换_Hive_Hiveql - Fatal编程技术网

Hive中的时间戳转换

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时间戳将无法工作。

我想将以下字符串值转换为配置单元中的时间戳

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时间戳将无法工作。我想你需要这个

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

也看到这个答案:太好了。谢谢