Re: Temporal query question - Mailing list pgsql-general

From Richard Huxton
Subject Re: Temporal query question
Date
Msg-id 41AC56D6.1000000@archonet.com
Whole thread Raw
In response to Temporal query question  ("Stefano Bonnin" <stefano.bonnin@comai.to>)
Responses Re: Temporal query question
List pgsql-general
Stefano Bonnin wrote:
> Hi all,
>
> I have a "simple" question about the following temporal query with
> "interval" operator:
>
> can I define a query of this type?
>
> select myfield,numeric_field from mytable where temporal_attribute <
> temporal_attribute - interval numeric_field || ' days'
>
> obviously this syntax is wrong.

Not by much:

SELECT now() - (1 || ' days')::interval;

You could use CAST(...) instead of course, and a date plus/minus an
integer defaults to days.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: change natural column order
Next
From: Richard Huxton
Date:
Subject: Re: Maximum limit on int in plpgsql