【问题标题】:Date conversion in postgrespostgres中的日期转换
【发布时间】:2013-08-29 20:13:18
【问题描述】:

我有这样的事情:

2010-09-14 00:00:00

并且想在上面的示例中只显示月/年或类似的内容:

9/10

我可以通过这样做来提取年份部分

select extract (year from E.DISCHARGE_DATE)as YR_NB 

但无法获得我希望在输出结果中看到的 9/10 结果。

【问题讨论】:

    标签: sql postgresql postgresql-9.1


    【解决方案1】:
    select to_char(the_date_column, 'mm/yy') from the_table;
    

    手册中的更多详细信息:http://www.postgresql.org/docs/current/static/functions-formatting.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-25
      • 2023-03-17
      • 2022-01-09
      • 1970-01-01
      • 2019-05-26
      • 2016-10-05
      • 1970-01-01
      • 2020-07-04
      相关资源
      最近更新 更多