Hive - UNIX_TIMESTAMP Quandary [英] Hive - UNIX_TIMESTAMP Quandary

查看:316
本文介绍了Hive - UNIX_TIMESTAMP Quandary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的1行数据(为简洁起见):

  73831 12/26/2014 1:00:00 AM 0.3220 

第二栏是时间字符串格式的列。我使用这个配置单元查询:

$ p $ select col2,UNIX_TIMESTAMP(col2,'MM / DD / YYYY hh:mm:ss aaa')from Table

以下是我得到的结果: 1388296800



然而,当我检查时, http: //www.epochconverter.com/ 以及 from_unixtime(1388296800),我会得到不同的日期。



我在格式/模式字符串中输入 UNIX_TIMESTAMP 在Hive中有什么问题吗?

解决方案

您的日期格式符号需要符合Java SimpleDateFormat文档



你的日期看起来像你想要的 MM / dd / yyyy HH :mm:ss aa


Here is my 1 line of data (for brevity):

73831   12/26/2014 1:00:00 AM   0.3220

The 2nd column is the time column which is in string format. I'm using this hive query:

select col2, UNIX_TIMESTAMP(col2,'MM/DD/YYYY hh:mm:ss aaa') from Table

Here is what I get: 1388296800

However, when I check with, http://www.epochconverter.com/ and also from_unixtime(1388296800), I get a different date.

Is there something wrong with my format / pattern string I enter into UNIX_TIMESTAMP in Hive?

解决方案

Your date format symbols need to conform to those in the Java SimpleDateFormat documentation.

For your date it looks like you want MM/dd/yyyy HH:mm:ss aa.

这篇关于Hive - UNIX_TIMESTAMP Quandary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆