【问题标题】:TIMESTAMP in hive?蜂巢中的时间戳?
【发布时间】:2016-04-21 12:52:06
【问题描述】:

我有一列,数据为 'Apr 06 2016 05:30:30' 它不在时间戳格式中,当使用这一列作为时间戳时,我得到空值。所以存储为字符串,现在我想在时间戳格式中对此进行一些计算。为此,我转换为 unixtimestamp 并返回时间戳格式,但日期的值已更改。我将转换用作 'select from_unixtime(unix_timestamp(start_time, 'MMM DD YYYY HH:mm:ss')) from temp;' 我得到的价值是'2015-12-27 05:30:30'。 我希望最终数据为 '2016-04-06 05:30:30'。

请帮帮我

【问题讨论】:

    标签: sql hive timestamp apache-spark-sql bigdata


    【解决方案1】:

    你刚才写错了格式。正确的格式字符串是'MMM dd yyyy HH:mm:ss'。查看https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html 以获取格式字符串的参考。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      相关资源
      最近更新 更多