--算法等於當前月份 to 當前月份 + 1個月-1天
SELECT * FROM test WHERE dt BETWEEN (SELECT (date_trunc('MONTH', now())::DATE)) AND (SELECT (date_trunc('MONTH', now()::DATE) + interval '1 month' - interval '1 day')::DATE);
參考資料:
https://www.postgresql.org/docs/11/functions-datetime.html
https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC