2020-08-21 18:08:07 +07:00
|
|
|
CREATE OR REPLACE FUNCTION add_months (datetime TIMESTAMP WITH TIME ZONE, months NUMERIC)
|
|
|
|
RETURNS TIMESTAMP WITH TIME ZONE AS $$
|
2009-03-25 12:02:55 +07:00
|
|
|
BEGIN
|
|
|
|
if datetime is null or months is null then
|
|
|
|
return null;
|
|
|
|
end if;
|
2020-08-21 18:08:07 +07:00
|
|
|
return datetime + (interval '1' month * TRUNC(months));
|
2009-03-25 12:02:55 +07:00
|
|
|
END;
|
2020-08-21 18:08:07 +07:00
|
|
|
$$ LANGUAGE plpgsql IMMUTABLE
|
2009-03-25 12:02:55 +07:00
|
|
|
;
|
2014-05-31 00:11:20 +07:00
|
|
|
|