How to convert unix time into date in druid or apache-druid

Viewed 1757

I want to use date_diff function in @druid. Where my input will be to unix_timestamp.

Unix_timestamp = 1597689016000

I want this to be converted into a timestamp where I can find the difference between two times.

Also please tell me, what is fiction to difference of both timestamps.

1 Answers

Try using the from_unixtime function, it expects seconds, and your timestamp is in milliseconds so divide by thousand:

from_unixtime(CAST(Unix_timestamp /1000 as BIGINT))

Sorry just saw it was in Druid, that shold work in presot. In Druid there is this function:

MILLIS_TO_TIMESTAMP(Unix_timestamp )
Related