【问题标题】:how to convert date 2017-sep-12 To 2017-09-12 in HIVE如何在 HIVE 中将日期 2017-sep-12 转换为 2017-09-12
【发布时间】:2017-11-15 07:14:30
【问题描述】:

我在转换 hive 中的日期时遇到了一个问题。我需要将 2017-sep-12 转换为 2017-09-12 。我如何在 HIVE 中实现这一点

【问题讨论】:

标签: hadoop hive hiveql


【解决方案1】:

使用unix_timestamp(string date, string pattern) 将给定的日期格式转换为从 1970-01-01 过去的秒数。然后使用from_unixtime() 转换成给定的格式:

hive> select from_unixtime(unix_timestamp('2017-sep-12' ,'yyyy-MMM-dd'), 'dd-MM-yyyy');
OK
12-09-2017

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 2018-02-17
    • 2018-02-20
    • 2023-03-05
    • 1970-01-01
    • 2017-01-26
    • 1970-01-01
    相关资源
    最近更新 更多