Re: type casting a subselect as an interval

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: type casting a subselect as an interval
Date: 2003-02-21 11:17:08
Message-ID: 20030221111708.GB21668@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Feb 21, 2003 at 07:59:19PM +0900, Jean-Christian Imbeault wrote:
> How can I cast the return value of a sub-select as an interval?
>
> Something like:
>
> select current_timestamp - interval '(select days from T) days'

You can cast it in the subselect:

select current_timestamp - (select (days::text || 'd')::interval from T);

Karel
--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2003-02-21 13:21:47 Re: Problem with aliasing
Previous Message Richard Huxton 2003-02-21 11:01:56 Re: cursors and column names