How to get the number of days in a month?

后端 未结 6 2033
梦毁少年i
梦毁少年i 2020-12-30 23:25

I am trying to get the following in Postgres:

select day_in_month(2);

Expected output:

28

Is there any bu

6条回答
  •  执笔经年
    2020-12-30 23:41

    This works as well.

    WITH date_ AS (SELECT your_date AS d)
    SELECT d + INTERVAL '1 month' - d FROM date_;
    

    Or just:

    SELECT your_date + INTERVAL '1 month' - your_date;
    

    These two return interval, not integer.

提交回复
热议问题