Re: convert integer to interval ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pilsl(at)goldfisch(dot)at
Cc: "postgres mailinglist" <pgsql-general(at)postgresql(dot)org>
Subject: Re: convert integer to interval ?
Date: 2003-02-09 00:08:26
Message-ID: 13755.1044749306@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Magnus Naeslund(f)" <mag(at)fbab(dot)net> writes:
> pilsl(at)goldfisch(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message gearond 2003-02-09 03:09:39 How to do unique users
Previous Message Nick Kelly 2003-02-08 23:04:49 configure: error: no acceptable C compiler found in $PATH