将 hh 中的时间戳转换为日期
我在Hive列中具有这种数据格式。
09/05/2015 12:45:00
我试图将其转换为这种格式,
20150905, or with semicolons - 2015-09-05
最有效的方法是什么,而无需浏览Linux时间戳?
I have this format of data in a hive column.
09/05/2015 12:45:00
I am trying to convert it to this format
20150905, or with semicolons - 2015-09-05
What is the most efficient way and without going through linux timestamp?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
date_format
。如果您的数据为字符串/时间戳/日期格式,
而且您需要一串格式
yyyy-mm-dd
,然后使用 -date_format(date_time_col,'yyyy-mm-dd')
而且您想要日期格式,然后使用 -
cast(date_format(date_time_col,'yyyy-mm-dd')作为日期)
edit
如果您有一个字符串的“ mm/dd/yyyy”,则需要将字符串分开并置为cont,然后将它们发送到date_format。
您可以将所有这些结合在一起 -
use
date_format
.If your data is in String/Timestamp/Date format,
and you want a string of format
yyyy-MM-dd
, then use-date_format(date_time_col, 'yyyy-MM-dd')
and you want a date format , then use-
cast( date_format(date_time_col, 'yyyy-MM-dd') as date)
EDIT
In case you have a string 'MM/dd/yyyy', you need to split the string and concat them before senting them to date_format.
And you can combine all like this -