Despicable me
Despicable me

Reputation: 700

How to convert unix/epoch timestamp into date string in Apache Phoenix SQL

We have created Phoenix views on top of Hbase tables and querying the data. One of the the columns holds epoch timestamp data and we need to convert it into a valid date format, couldn't find any appropriate functions, any help much appreciated.

Upvotes: 2

Views: 3349

Answers (1)

erkan
erkan

Reputation: 76

If type of "the column holds epoch timestamp data" is INTEGER or BIGINT, you can use:

CAST("epoch_time" AS TIMESTAMP)

if its type is VARCHAR, you should first convert value to number through TO_NUMBER() built-in function, i.e.

CAST(TO_NUMBER("epoch_time") AS TIMESTAMP)

Upvotes: 3

Related Questions