SQL、PRESTO使用to_unixtime时间函数计算两个‘年月日时分秒’时间戳的时间间隔

例如 a.apply_time 是2020-05-11 13:54:27
b.su_time是2020-03-25 11:20:44
怎么计算两个‘年月日时分秒’时间戳的时间间隔呢?

SELECT to_unixtime(cast(a.apply_time as timestamp)) - to_unixtime(cast(b.su_time as timestamp)) as intervel
即可获得两个时间戳的时间间隔,单位为秒,/60或者/(60*24)换算为天即可。

其他关于presto hive的时间函数可以参考:

SQL、PRESTO使用to_unixtime时间函数计算两个‘年月日时分秒’时间戳的时间间隔