Re: rounding timestamps - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: rounding timestamps
Date
Msg-id 20031124032741.GA15475@dcc.uchile.cl
Whole thread Raw
In response to rounding timestamps  ("Claudio Lapidus" <clapidus@hotmail.com>)
List pgsql-general
On Mon, Nov 24, 2003 at 12:15:54AM -0300, Claudio Lapidus wrote:

> But my problem is that to_char truncates the fractional seconds, and I need
> to round the value to the nearest integer second. In the above, I would need
> the output rounded to 15:31:00, which is just a millisecond away, for
> example. But I couldn't find a function to round a timestamp. Are there any
> workaround?

Maybe you can try with EXTRACT(epoch FROM timestamp), rounding that, and
then converting back to a timestamp through abstime.  Ugly though ...

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Hoy es el primer día del resto de mi vida"

pgsql-general by date:

Previous
From: "Claudio Lapidus"
Date:
Subject: rounding timestamps
Next
From: Joe Conway
Date:
Subject: Re: rounding timestamps