HiveSQL时间差计算

1
2
3
4
5
6
7
8
9
10
11
-- 两个时间相差的秒数
select cast((unix_timestamp() - unix_timestamp('2021-09-23 00:00:00')) as bigint)

-- 两个时间相差的分钟数
select cast((unix_timestamp() - unix_timestamp('2021-09-23 00:00:00'))/(60) as bigint)

-- 两个时间相差的小时数
select cast((unix_timestamp() - unix_timestamp('2021-09-23 00:00:00'))/(60 * 60) as bigint)

-- 两个时间相差的天数
select cast((unix_timestamp() - unix_timestamp('2021-09-23 00:00:00'))/(60 * 60 * 24) as bigint)
0%