| From: | Michael Fuhr <mike(at)fuhr(dot)org> |
|---|---|
| To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
| Cc: | Magdalena Komorowska <meluzyna(at)w3(dot)net(dot)pl>, pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Date Interval |
| Date: | 2005-12-06 17:09:02 |
| Message-ID: | 20051206170902.GA97204@winnie.fuhr.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Tue, Dec 06, 2005 at 11:54:05AM -0500, Bruce Momjian wrote:
> test=> SELECT current_timestamp + cast(x || ' months' AS INTERVAL) FROM
> test;
> ?column?
> -------------------------------
> 2006-03-06 11:53:05.574279-05
> (1 row)
Or another way:
test=> CREATE TABLE test (x numeric);
CREATE TABLE
test=> INSERT INTO test VALUES (3);
INSERT 0 1
test=> SELECT current_timestamp + x * interval'1 month' FROM test;
?column?
-------------------------------
2006-03-06 12:07:48.112765-05
(1 row)
--
Michael Fuhr
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2005-12-06 17:12:46 | Re: [SQL] lost in system tables |
| Previous Message | Bruce Momjian | 2005-12-06 16:54:05 | Re: Date Interval |