Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgres Sql中当月的最后日期_Sql_Postgresql - Fatal编程技术网

Postgres Sql中当月的最后日期

Postgres Sql中当月的最后日期,sql,postgresql,Sql,Postgresql,如何在Postgresql中通过月份名称获取月份的最后一天 SELECT DATE_PART('days', DATE_TRUNC('month', NOW()) + '1 MONTH'::INTERVAL - DATE_TRUNC('month', NOW()) ) 您现在可以使用任何日期来代替请尝试以下方法: select date_trunc('month', to_date('January ', 'Month'))+'1month'::inter

如何在Postgresql中通过月份名称获取月份的最后一天

SELECT  
    DATE_PART('days', DATE_TRUNC('month', NOW()) 
        + '1 MONTH'::INTERVAL - DATE_TRUNC('month', NOW())
    )
您现在可以使用任何日期来代替

请尝试以下方法:

select date_trunc('month', to_date('January ', 'Month'))+'1month'::interval-'1day'::interval
to_date('January', 'Month')
要从月份名称解析日期对象,可以尝试以下方法:

select date_trunc('month', to_date('January ', 'Month'))+'1month'::interval-'1day'::interval
to_date('January', 'Month')

谢谢斯塔科。我刚刚编辑了我的问题。你能再看看吗?谢谢,阿莱洛。但是,我想用月份名称(比如:一月)来代替当前的日期。有可能吗?谢谢Chandran。但我想在现在的地方度过一个月(比如:一月)。可能吗?您需要立即给出格式,而不仅仅是月份名称,尝试给出“2015-05-12 00:00:00”