YYYY-MM column type in PostgreSQL

前端 未结 2 521
一生所求
一生所求 2021-01-19 08:11

I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don\'t know if there is a column data type for this type of need. If no

2条回答
  •  广开言路
    2021-01-19 08:34

    If you are interested in display values in YYYY-MM formt you can use to_char(your_datatime_colum,'YYYY-MM')

    example:

    SELECT to_char(now(),'YYYY-MM') as year_month
    

提交回复
热议问题