Re: Date Math

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Subject: Re: Date Math
Date: 2007-05-07 18:51:01
Message-ID: 200705071151.01414.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday 07 May 2007 10:56 am, Rich Shepard wrote:
> On Mon, 7 May 2007, Adrian Klaver wrote:
> > If term and process_time are stored as intervals then it will work. Also
> > if they are stored as INTERVALS you can do CURRENT_DATE+process_time. In
> > other words not have to declare the INTERVAL . Is date_issued stored as a
> > date? If so it would not need to be cast.
>
> Adrian,
>
> Here are the pertinent declarations in the DDL:
>
> date_issued DATE NOT NULL
> CONSTRAINT invalid_date
> CHECK (date_applied <= date_issued),
> term SMALLINT DEFAULT 1 NOT NULL, -- in years
> processing_time DEFAULT 180 NOT NULL SMALLINT, -- in days
>
> Thanks,
>
> Rich
With this setup you will have to use an explicit string-
date_issued + INTERVAL term|| 'years'. This will involve constructing a
string and passing it to INTERVAL. The alternative is to change the column
types of term and processing_time to interval and store the interval period
with the interval qty i.e '1 year' for term and '400 days' for processing
time for example. This way the you can use the values directly without
invoking INTERVAL.

--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2007-05-07 18:58:06 PITR and tar
Previous Message Jaime Silvela 2007-05-07 18:45:08 Re: linux bug and lost rows