TheNewGuy
TheNewGuy

Reputation: 579

Convert Unixtime to MMddyyyy

I'm trying to convert a column which has unixtime (ex 1542862806000) to regular DTS

select unix_timestamp(column_name) from table;

But i get error:

AnalysisException: No matching function with signature: unix_timestamp(BIGINT).

My column type is bigint

Upvotes: 0

Views: 333

Answers (1)

Vamsi Prabhala
Vamsi Prabhala

Reputation: 49260

You are looking for from_unixtime not unix_timestamp.

select from_unixtime(cast(column_name/1000 as bigint),'MMddyyyy') 
from table

unix_timestamp converts a date/date format string to a bigint representing the number of seconds since 1970-01-01 00:00:00 UTC.

from_unixtime takes a bigint input and converts it to the required date format.

Upvotes: 1

Related Questions