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

From Bruno Wolff III
Subject Re: Interval constant syntax, was Re: Interval & check clause
Date
Msg-id 20040329204410.GA7968@wolff.to
Whole thread Raw
In response to Interval constant syntax, was Re: Interval & check clause  ("Karl O. Pinc" <kop@meme.com>)
Responses Re: Interval constant syntax, was Re: Interval & check clause
List pgsql-general
On Mon, Mar 29, 2004 at 13:58:51 -0600,
  "Karl O. Pinc" <kop@meme.com> wrote:
>
> 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.)

In postgres you shouldn't have to explicitly cast the constant to an
interval as long as there isn't one than one >= operator that could
be applied (depending on the eventaul type of the constant). I would
really be surprized if this were to happen for >= and an interval operand
on one side or the other.

It won't work with two unknown constants, if that was what you tested.
Try just casting on one side.

P.S.
I think :: is easier to read than a CAST function call, so that is what
I am in the habit of using.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: bugs list working???
Next
From: Tom Lane
Date:
Subject: Re: PG vs MySQL