pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Bruce Momjian <pgman@candle.pha.pa.us>
Cc: Magdalena Komorowska <meluzyna@w3.net.pl>
Cc: pgsql-sql@postgresql.org
Subject: Re: Date Interval
Date: Tue, 6 Dec 2005 10:09:02 -0700
Message-ID: <20051206170902.GA97204@winnie.fuhr.org> (raw)
In-Reply-To: <200512061654.jB6Gs5d14178@candle.pha.pa.us>
References: <20051206135906.ECA9713E35@spinet.pl>
	<200512061654.jB6Gs5d14178@candle.pha.pa.us>

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



view thread (8+ messages)  latest in thread

Message-ID: <20051206170902.GA97204@winnie.fuhr.org>
Permalink:  ../20051206170902.GA97204@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20051206170902.GA97204@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, pgman@candle.pha.pa.us, meluzyna@w3.net.pl
  Subject: Re: Date Interval
  In-Reply-To: <20051206170902.GA97204@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox