Re: casting for dates - Mailing list pgsql-hackers

From Andrew McMillan
Subject Re: casting for dates
Date
Msg-id 1001537839.2178.2.camel@kant.mcmillan.net.nz
Whole thread Raw
In response to casting for dates  (Vince Vielhaber <vev@michvhf.com>)
Responses Re: casting for dates  (Vince Vielhaber <vev@michvhf.com>)
List pgsql-hackers
On Thu, 2001-09-27 at 08:30, Vince Vielhaber wrote:
> 
> I'm trying to use an integer from a table to add/subtract time in months.
> IOW:
> 
> create table foo(nummonths int);
> 
> select now() - nummonths months;

newsroom=# select now() - interval( text(3) || ' months');       ?column?        
------------------------2001-06-27 08:56:27+12
(1 row)


Crude, but hey: it works :-)

Cheers,                SAndrew.
-- 
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7217    MOB: +64(21)635-694    OFFICE: +64(4)499-2267



pgsql-hackers by date:

Previous
From: Vince Vielhaber
Date:
Subject: casting for dates
Next
From: Neil Padgett
Date:
Subject: Re: Spinlock performance improvement proposal