【问题标题】:Convert bignit to date (month name)将 bigint 转换为日期(月份名称)
【发布时间】:2021-01-01 05:39:56
【问题描述】:

我需要将字段转换为日期。

目前该字段是月份 (1, 2, 3....) 的整数,我想将其转换为“一月、二月、三月....”

如何编写 SQL (Presto) 以将其从 bigint 转换为 date?

【问题讨论】:

    标签: sql date type-conversion presto bigint


    【解决方案1】:

    这行得通吗?

    select date_format(str_to_date('2000-' || 1 || '-01'), '%Y-%m-%d'), '%M')
    

    【讨论】:

      【解决方案2】:

      Presto 没有小提琴所以我没有测试过这个,但是看看这是否能解决问题

      select date_format(date_add(month, your_integer_month, '2020-12-31'),'%M') 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-29
        • 1970-01-01
        • 2016-03-09
        • 2018-12-21
        • 1970-01-01
        • 2017-02-07
        相关资源
        最近更新 更多