首页 > 解决方案 > 将 Unixtime 转换为 MMddyyyy

问题描述

我正在尝试将具有 unixtime(例如 1542862806000)的列转换为常规 DTS

select unix_timestamp(column_name) from table;

但我得到错误:

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

我的列类型是 bigint

标签: sqlimpala

解决方案


你要找的from_unixtime不是unix_timestamp

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

unix_timestamp将日期/日期格式字符串转换为表示自UTCbigint以来的秒数。1970-01-01 00:00:00

from_unixtime接受bigint输入并将其转换为所需的日期格式。


推荐阅读