📜  月间的 postgresql - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:12.244000             🧑  作者: Mango

代码示例4
CREATE OR REPLACE FUNCTION public.fn_getlastofmonth (
  date
)
RETURNS date AS
$body$
begin
    return (to_char(($1 + interval '1 month'),'YYYY-MM') || '-01')::date - 1;
end;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
--------------------------------------------------------------------------------
WHERE date >= '2012-01-01' 
  AND date < fn_getlastofmonth('2013-04-01')