postgres 获取月初月末日期

https://knowledge.reontosanta.com/archives/14


select date_trunc('month',now())


select date_trunc('month',now()+'1 months')+'-1 days'

同理获取当天:


select date_trunc('day',now());
-- 当季第一天
select date_trunc('quarter',now());
-- 当周第一天:
select date_trunc('week',now());
-- 小时 取整:
select date_trunc('hour',now());
原文地址:https://www.cnblogs.com/qianxunman/p/13973264.html