Date in mmm yyyy format in postgresql

后端 未结 5 1261

I have a table with a column of type timestamp without time zone.

I want to select that column with the mmm yyyy format – for example, “Mar 2011”. How to f

相关标签:
5条回答
  • 2021-02-01 13:50

    You need to use a date formatting function for example to_char http://www.postgresql.org/docs/current/static/functions-formatting.html

    0 讨论(0)
  • 2021-02-01 13:51

    I think in Postgres you can play with formats for example if you want dd/mm/yyyy

    TO_CHAR(submit_time, 'DD/MM/YYYY') as submit_date
    
    0 讨论(0)
  • 2021-02-01 13:52

    You can write your select query as,

    select * from table_name where to_char(date_time_column, 'YYYY-MM')  = '2011-03';
    
    0 讨论(0)
  • 2021-02-01 13:54

    SELECT TO_CHAR(NOW(), 'Mon YYYY');

    0 讨论(0)
  • 2021-02-01 13:54

    DateAndTime Reformat:

    SELECT *, to_char( last_update, 'DD-MON-YYYY') as re_format from actor;
    

    DEMO:

    0 讨论(0)
提交回复
热议问题