How to get the last day of month in postgres?

前端 未结 5 1457
醉话见心
醉话见心 2020-12-18 17:47

How to find the last day os the month in postgres? I have a date columns stored as numeric(18) in the format(YYYYMMDD) I am trying it to make it date using

         


        
5条回答
  •  长情又很酷
    2020-12-18 18:35

    For future searches, Redshift does not accept INTERVAL '1 month'. Instead use dateadd(month, 1, date) as documented here.

    To get the end of the month use: DATEADD(DAY, -1, (DATE_TRUNC('month', DATEADD(MONTH, 1, date))))

提交回复
热议问题