【问题标题】:Convert yyyymm String to yyyy-mm-dd hh:mm:ss date time in athena在雅典娜中将 yyyymm 字符串转换为 yyyy-mm-dd hh:mm:ss 日期时间
【发布时间】:2021-07-16 06:07:05
【问题描述】:

我正在尝试将字符串列“yyyymm”转换为 athena 中的“yyyy-mm-dd hh:mm:ss”日期时间列。

我该怎么做?

【问题讨论】:

    标签: sql database amazon-web-services amazon-athena presto


    【解决方案1】:

    这是你想要的吗?:

    select date_parse(strdatecol,'%b-%d-%Y')
    from table
    

    【讨论】:

      【解决方案2】:

      date_parse() 在这种情况下工作得很好。它读取一个字符串值,即字符串值的格式,然后将该字符串值转换为日期时间值。在本例中,yyyymm 作为字符串传递,格式为年月值。

      这给了我想要的结果:

      SELECT date_parse('yyyymm', '%Y%m')
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-03-16
        • 1970-01-01
        • 2019-09-03
        • 1970-01-01
        • 1970-01-01
        • 2021-08-29
        • 1970-01-01
        • 2020-12-19
        相关资源
        最近更新 更多