Re: convert integer to interval ? - Mailing list pgsql-general

From Tom Lane
Subject Re: convert integer to interval ?
Date
Msg-id 13755.1044749306@sss.pgh.pa.us
Whole thread Raw
In response to Re: convert integer to interval ?  ("Magnus Naeslund(f)" <mag@fbab.net>)
List pgsql-general
"Magnus Naeslund(f)" <mag@fbab.net> writes:
> pilsl@goldfisch.at wrote:
>> something like
>> select current_timestamp+interval '7 days';

> Is there any reason why you can't do:

> sprintf(buf,"select current_timestamp+interval '%d days'",int_days);

Also, if you really only want the result to the nearest day, date
arithmetic (as opposed to timestamp arithmetic) works the way you want.
For example,

regression=# select current_date, current_date + 7;
    date    |  ?column?
------------+------------
 2003-02-08 | 2003-02-15
(1 row)


            regards, tom lane

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: convert integer to interval ?
Next
From: gearond@cvc.net
Date:
Subject: How to do unique users