Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate seconds between two timestamps in Impala?

I do not see an Impala function to subtract two datestamps and return seconds (or minutes) between the two. http://www.cloudera.com/documentation/archive/impala/2-x/2-0-x/topics/impala_datetime_functions.html

like image 214
ADJ Avatar asked Mar 07 '16 19:03

ADJ


People also ask

How do you calculate seconds between two timestamps?

Discussion: If you'd like to calculate the difference between the timestamps in seconds, multiply the decimal difference in days by the number of seconds in a day, which equals 24 * 60 * 60 = 86400 , or the product of the number of hours in a day, the number of minutes in an hour, and the number of seconds in a minute.

Does Impala support timestamp?

Because Impala implicitly converts string values into TIMESTAMP , you can pass date/time values represented as strings (in the standard yyyy-MM-dd HH:mm:ss. SSS format) to this function.

How do you subtract days from date in Impala?

from_timestamp(timestamp_data, 'yyyyMMdd') - This converts a date to a desired string format. -interval 2 days - This takes date time back to 2days before system date.


1 Answers

unix_timestamp(finish_time)-unix_timestamp(start_time) will give you the seconds between them.

like image 199
Harper Koo Avatar answered Sep 23 '22 22:09

Harper Koo