Adding dates in plpgsql - Mailing list pgsql-general

From Stuart Grimshaw
Subject Adding dates in plpgsql
Date
Msg-id E15wkBD-0006lY-00@garner.smgsystems.co.uk
Whole thread Raw
Responses Re: Adding dates in plpgsql
List pgsql-general
I have a trigger that needs to do some addition to dates,

CREATE FUNCTION update_dis_record () RETURNS OPAQUE AS '
DECLARE
    tmpYellow INTEGER;
    tmpBan_Starts timestamp;
BEGIN
    tmpYellow := NEW.yellow % 5;
    tmpBan_Starts := now + "14 Days";
    IF tmpYellow = 0 AND NEW.yellow <> 0 THEN
        NEW.length := NEW.length + 1;
        NEW.ban_starts := tmpBan_Starts;
    END IF;

    IF NEW.ban_starts <> null THEN
        NEW.ban_starts := OLD.ban_starts;
    END IF;

    RETURN NEW;
END;
' LANGUAGE 'plpgsql';

The line "tmpBan_Starts := now + "14 Days"; " doesn't work obviously, but
what is the correct way to ad 14 (or any number of ) days to a date with
plpgsql?

--

| Stuart Grimshaw <stuart@footballnet.com>
| Chief Operations Officer
| Football Networks Ltd
|-
| t:07976 625221
| f:0870 7060260

pgsql-general by date:

Previous
From: Basilio Briceno
Date:
Subject: Re: Importing Access 97 Database into 7.1.3
Next
From: Keary Suska
Date:
Subject: Re: Where is the library?