内容简介:翻译自:https://stackoverflow.com/questions/28186014/how-to-get-the-last-day-of-month-in-postgres
如何在postgres中查找月份的最后一天?
我有一个日期列存储为数字(18)格式(YYYYMMDD)
我正在尝试使用它来约会
to_date("act_dt",'YYYYMMDD') AS "act date"
然后找到这个日期的最后一天:
像这样:
(select (date_trunc('MONTH',to_date("act_dt",'YYYYMMDD')) + INTERVAL '1 MONTH - 1 day')::date)
但它给了我这个错误:
ERROR: Interval values with month or year parts are not supported Detail: ----------------------------------------------- error: Interval values with month or year parts are not supported code: 8001 context: interval months: "1" query: 673376 location: cg_constmanager.cpp:145 process: padbmaster [pid=20937] -----------------------------------------------
有帮助吗?
Postgres版本:
i686-pc-linux-gnu上的PostgreSQL 8.0.2,由GCC gcc(GCC)3.4.2 20041017(Red Hat 3.4.2-6.fc3)编译,Redshift 1.0.874
翻译自:https://stackoverflow.com/questions/28186014/how-to-get-the-last-day-of-month-in-postgres
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Practical Algorithms for Programmers
Andrew Binstock、John Rex / Addison-Wesley Professional / 1995-06-29 / USD 39.99
Most algorithm books today are either academic textbooks or rehashes of the same tired set of algorithms. Practical Algorithms for Programmers is the first book to give complete code implementations o......一起来看看 《Practical Algorithms for Programmers》 这本书的介绍吧!