Hive - 以分钟为单位的时差为负

Hive - time difference in minutes is negative

我需要获取以分钟为单位的时差,以便在 Hive 查询中进行分析。

我正在使用 unix_timestamp() 将日期转换为秒,然后减去以秒为单位的差异,然后乘以 60 以分钟为单位。

我的问题是我最近的约会 - 较早的日期差异变为负值。

这是我的查询和结果

Hive query and result screenshot

processed_ts create_ts processed_unix_timestamp create_unix_timestamp miniue Diff 2017-03-12 3:01:06 2017-03-12 2:58:36 1489312865 1489316315 -57.5 2017-03-12 3:01:36 2017-03-12 2:59:06 1489312895 1489316345 -57.5 2017-03-12 3:02:12 2017-03-12 2:59:42 1489312932 1489316382 -57.5

非常感谢任何帮助。

USA & Canada Start DST on March 12
Published 17-Feb-2017

Most of the United States, Canada, and Mexico's northern border cities will begin Daylight Saving Time (DST) on Sunday, March 12, 2017.

People in areas that observe DST will spring forward 1 hour from 02:00 (2 am) to 03:00 (3 am), local time. Standard time will resume on Sunday, November 5, 2017.

https://www.timeanddate.com/news/time/usa-canada-start-dst-2017.html


select timestamp '2017-03-12 02:58:36'

2017-03-12 03:58:36