问题描述
首先我尝试了代码,我在日期文件中添加了一个列DateTime.Ticks(635677577653488758),我试图将它转换为Hadoop Hive的Date。在MySql下面阻止它,它的工作。但是,与Hive相同的代码并不起作用,因为date_add函数适用于INT。
SELECT DATE_ADD('2001-01-01 00:00:00',INTERVAL(MAX(f.date) - 631139040000000000)/ 10 MICROSECOND);
然后我将格式化这样...
SELECT DATE_FORMAT(MyDateFromTicks,'%Y-%m-%dT%T.%fZ');
我该如何实现?
谢谢。
我找到了解决方案。我在这里写下来,所以如果有人来这么远可以检查答案:)
我的昵称:635683895215023579
EPOCH Ticks:621355968000000000
SELECT FROM_UNIXTIME(CAST((635683895215023579 - 621355968000000000)/ 10000000 as BIGINT),'yyyy-MM -dd\'T\HH:mm:ss.SSSZ');
I have log file with a column in DateTime.Ticks (635677577653488758) which i am trying to convert it to Date in Hadoop Hive.
First i tried the code block below on MySql and it worked. But the same code didn't work in Hive because date_add function works with INT.
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL (MAX(f.date) - 631139040000000000)/10 MICROSECOND);
Then i will format it like this...
SELECT DATE_FORMAT(MyDateFromTicks, '%Y-%m-%dT%T.%fZ');
How can i achieve this?
Thank you.
I've found the solution. I am writing it down here so if anyone comes this far can check the answer :)
My Ticks: 635683895215023579
EPOCH Ticks: 621355968000000000
SELECT FROM_UNIXTIME(CAST((635683895215023579 - 621355968000000000)/10000000 as BIGINT),'yyyy-MM-dd\'T\'HH:mm:ss.SSSZ');
这篇关于如何将.net DateTime.Ticks转换为Hive DateTime在查询中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!