简体   繁体   English

蜂巢投放日期

[英]hive casting date

In a hive table I have bunch of date that are in integer format. 在配置单元表中,我有一堆整数形式的日期。

Example

Table

Date
2015051517
2015051518
2015081517

Query 询问

SELECT CAST(date TO INT)
FROM date_table;

How do I get the above example like below? 如何获得上面的示例,如下所示?

date
-------------
2015-05 15:17 
2015-05 15:18
2015-08 15:17

Thanks in advance!i 在此先感谢!

Since your date columns are in integer datatype, cast them as string and use Hive's built-in date functions. 由于您的日期列为整数数据类型,因此将其转换为字符串并使用Hive的内置日期函数。

Here what you need: 这里您需要什么:

select date_format(from_unixtime(unix_timestamp(cast(your-column as string),'yyyyMMHHmm')),'yyyy-MM HH:mm') from table;

The above code gave me the following results. 上面的代码给了我以下结果。

2015-05 15:17 
2015-05 15:18
2015-08 15:17
Time taken: 0.088 seconds, Fetched: 3 row(s)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM