蜂巢中的日期格式
Date format in hive
table 有 DEPNO DATE 它包含 2 条记录:
1 2004-05-02
2 03-APR-04
我想在配置单元
中以 yyyy-mm-dd 格式处理以上 2 个记录日期
您可以通过以下方式尝试:
select TO_DATE(from_unixtime(UNIX_TIMESTAMP(recordDate, 'yyyy-mm-dd'))) from table_name
参考Hive Date Functions了解更多详情
几个选项
1. 使用 UDF 获取列和 return 您想要的任何格式。
2. 用例 when 语句 like
select CASE WHEN length(col) = 10 then unix_timestamp(col, 'yyyy-MM-dd')
else unix_timestamp(col, 'yy-MMM-dd') from whatever.
table 有 DEPNO DATE 它包含 2 条记录: 1 2004-05-02 2 03-APR-04 我想在配置单元
中以 yyyy-mm-dd 格式处理以上 2 个记录日期您可以通过以下方式尝试:
select TO_DATE(from_unixtime(UNIX_TIMESTAMP(recordDate, 'yyyy-mm-dd'))) from table_name
参考Hive Date Functions了解更多详情
几个选项 1. 使用 UDF 获取列和 return 您想要的任何格式。 2. 用例 when 语句 like
select CASE WHEN length(col) = 10 then unix_timestamp(col, 'yyyy-MM-dd')
else unix_timestamp(col, 'yy-MMM-dd') from whatever.