【问题标题】:Need time stamp in "MMM-yyyy" format in hive在配置单元中需要“MMM-yyyy”格式的时间戳
【发布时间】:2017-07-29 08:33:47
【问题描述】:

您能帮我从 hive 中的 current_date 获取“MMM-yyyy”格式的时间格式吗?

非常感谢。

例如:

col1           col2
12-09-2016     SEP-2016
21-10-2017     OCT-2017

【问题讨论】:

    标签: datetime hadoop hive hiveql bigdata


    【解决方案1】:
    select from_unixtime(unix_timestamp(CURRENT_DATE, 'yyyy-MM-dd HH:mm:ss'),'MMM-yyyy') 
    AS currentdate from db.table_name;
    

    例子:

    hive> select from_unixtime(unix_timestamp(CURRENT_DATE, 'yyyy-MM-dd HH:mm:ss'),'MMM-yyyy')
        > AS currentdate from default.test limit 1;
    OK
    Jul-2017
    Time taken: 0.043 seconds, Fetched: 1 row(s)
    hive>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-29
      • 2019-04-17
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多