Re: Setting expire date on insert/modify

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: "Foster, Stephen" <stephenlfoster(at)comcast(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Setting expire date on insert/modify
Date: 2006-01-25 01:18:27
Message-ID: 20060124171515.U43544@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 24 Jan 2006, Foster, Stephen wrote:

> CREATE OR REPLACE FUNCTION "TF_BannerAd_Ads_InsMod"()
> RETURNS "trigger" AS
> $BODY$
> DECLARE
> ExpireDate timestamptz; -- Date the Banner Ad will expire.
> StartDate char(10); -- Date the Banner Ad was created or
> renewed
> NumOfDays char(10); -- Number of Dates the Ad will be in
> place.
> BEGIN
> StartDate := to_char(NEW.bannerad_creationdate, 'YYYY-MM-DD');
> NumOfDays := to_char(NEW.bannerad_term, '99999');
> ExpireDate := (date 'StartDate' + integer 'NumOfDays');

I think something like:

ExpireDate := CAST(NEW.bannerad_creationdate as Date) + NEW.bannerad_term;

may work for you.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2006-01-25 01:27:24 Re: Postgresql Segfault in 8.1
Previous Message Michael Glaesemann 2006-01-25 01:18:04 Re: Setting expire date on insert/modify