Adding dates in plpgsql

From: Stuart Grimshaw <stuart(at)smgsystems(dot)co(dot)uk>
To: psql-general <pgsql-general(at)postgresql(dot)org>
Subject: Adding dates in plpgsql
Date: 2001-10-25 13:04:14
Message-ID: E15wkBD-0006lY-00@garner.smgsystems.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)footballnet(dot)com>
| Chief Operations Officer
| Football Networks Ltd
|-
| t:07976 625221
| f:0870 7060260

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben-Nes Michael 2001-10-25 13:23:22 Re: Disable Transaction - plans ?
Previous Message Lee Kindness 2001-10-25 13:01:26 createuser -HELP!!