Reputation: 737
How to to compute datediff by hour in impala? For example like below
Select datediff(hour,'2017-06-21T02:29:54.244720804Z', '2017-06-21T02:30:10.574379557Z');
Default impala 'datediff' function only returns diff by day..
Update: Solution I figured
select cast(abs((unix_timestamp('2017-08-01 01:00:00', 'yyyy-MM-dd HH:mm:ss') - unix_timestamp('2017-08-01 00:00:00', 'yyyy-MM-dd HH:mm:ss'))/3600) as int);
Upvotes: 2
Views: 7033
Reputation: 3276
You can apply this workaround,
select datediff(time_a, time_b)*24 + hour(time_a) - hour(time_b);
Upvotes: 1