core-jgi/db/postgresql/functions/Add_Months.sql

12 lines
298 B
MySQL
Raw Permalink Normal View History

CREATE OR REPLACE FUNCTION add_months (datetime TIMESTAMP WITH TIME ZONE, months NUMERIC)
RETURNS TIMESTAMP WITH TIME ZONE AS $$
BEGIN
if datetime is null or months is null then
return null;
end if;
return datetime + (interval '1' month * TRUNC(months));
END;
$$ LANGUAGE plpgsql IMMUTABLE
;