Re: Dynamic Query for System functions - now()

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Kumar <sgnerd(at)yahoo(dot)com(dot)sg>
Cc: psql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Dynamic Query for System functions - now()
Date: 2003-11-10 15:30:26
Message-ID: 20031110072842.K16647@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 10 Nov 2003, Kumar wrote:

> select now()+ interval'1 month'; -- This is working fine.
>
> I wanna dynamically assign the interval number. i,e --> select now()+
> interval'n month';

If n is an integer, I'd suggest something like
select now() + n * interval '1 month';
rather than messing around with the text of the interval literal.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2003-11-10 15:43:42 Re: transaction processing after error in statement
Previous Message Christoph Haller 2003-11-10 14:05:02 Re: Dynamic Query for System functions - now()