Re: Temporal query question

From: Richard Huxton <dev(at)archonet(dot)com>
To: Stefano Bonnin <stefano(dot)bonnin(at)comai(dot)to>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Temporal query question
Date: 2004-11-30 11:17:42
Message-ID: 41AC56D6.1000000@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-11-30 11:18:44 Re: Maximum limit on int in plpgsql
Previous Message Richard Huxton 2004-11-30 11:15:57 Re: change natural column order