Interval constant syntax, was Re: Interval & check clause

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Bruno BAGUETTE <pgsql-ml(at)baguette(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Interval constant syntax, was Re: Interval & check clause
Date: 2004-03-29 19:58:51
Message-ID: 20040329135851.K9609@mofo.meme.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 2004.03.29 09:40 Bruno Wolff III wrote:
> On Mon, Mar 29, 2004 at 14:30:14 +0200,
> Bruno BAGUETTE <pgsql-ml(at)baguette(dot)net> wrote:
> > Hello,
> >
> > It may be a stupid question, but I'm looking to set a check clause
> in order
> > to be sure that a INTERVAL field is 00:00:00 or higher, but NOT
> negatives
> > values.
> >
> > How can I set that ?
>
> check (col_name >= '0 day'::interval)

Is there any way to write a constant interval without a cast?
It sure seems awkward to always have to cast. (AT least I always
seem to have to cast after my little bit of experiementing.)

(BTW, check (col_name >= CAST ('0 days' AS interval))
is more portable.)

Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-03-29 20:11:32 Re: bugs list working???
Previous Message scott.marlowe 2004-03-29 19:54:11 Re: PG vs MySQL