Hive SQL - 将(不追加)秒添加到现有时间戳



我正在尝试向现有时间戳添加秒以查找结束时间。我在一个字段中有开始时间,在一个字段中有总持续时间。我怎么能添加。 我尝试使用date_add功能,但这不起作用。

Select
      testdate, 
      DATE_ADD ( testdate,CAST (testduration as INT) ) as Test_end_date  
from <DBName>  limit 10;
TestDate is this format= 9/14/2017 16:33:25.000000
Testduration is in seconds e.g: 144 seconds or so

它添加到日期而不是秒组件。

任何帮助,不胜感激。

尝试Date_Add功能,不起作用。

使用 unix_timestamp 转换为秒,添加秒数

select from_unixtime(UNIX_TIMESTAMP('9/14/2017 16:33:25.000000','M/dd/yyyy HH:mm:ss.SSSSS')+144, 'yyyy-MM-dd HH:mm:ss.SSSSS')

这将以标准 Hive 时间戳格式返回时间戳,如果需要保留原始格式,请更改输出格式:"M/dd/yyyy HH:mm:ss。SSSSS"作为from_unixtime()函数的第二个参数。

最新更新