select date_trunc('month',current_date)2013-08-01 00:00:00-04
删除时间,转换到目前为止。@H_502_8@
select cast(date_trunc('month',current_date) as date)2013-08-01
如果您确定该列应该始终只存储一个月的第一个,您还应该使用一个CHECK约束。@H_502_8@
create table foo ( first_of_month date not null check (extract (day from first_of_month) = 1));insert into foo (first_of_month) values ('2015-01-01'); --Succeedsinsert into foo (first_of_month) values ('2015-01-02'); --Fails
ERROR: new row for relation "foo" violates check constraint "foo_first_of_month_check"DETAIL: Failing row contains (2015-01-02).总结
以上是内存溢出为你收集整理的postgresql – 在postgres中获取月份的第一个日期全部内容,希望文章能够帮你解决postgresql – 在postgres中获取月份的第一个日期所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)