Interval constant syntax, was Re: Interval & check clause - Mailing list pgsql-general

From Karl O. Pinc
Subject Interval constant syntax, was Re: Interval & check clause
Date
Msg-id 20040329135851.K9609@mofo.meme.com
Whole thread Raw
In response to Re: Interval & check clause  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: Interval constant syntax, was Re: Interval & check clause
List 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@baguette.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@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein

pgsql-general by date:

Previous
From:
Date:
Subject: Re: 7.4.2 on Solaris 9 - Error
Next
From: "scott.marlowe"
Date:
Subject: Re: PG vs MySQL