On 03/07/2012 08:11 PM, Daniele Varrazzo wrote:
On Wed, Mar 7, 2012 at 3:09 PM, Andy Colsona...@squeakycode.net wrote:
Took me a while to figure this out, thought I'd paste it here for others to
use:
create or replace function round_timestamp(timestamp, integer) returns
timestamp as $$
Took me a while to figure this out, thought I'd paste it here for others
to use:
create or replace function round_timestamp(timestamp, integer) returns
timestamp as $$
select date_trunc('minute', $1) + cast(round(date_part('seconds',
$1)/$2)*$2 || ' seconds' as interval);
$$ language sql
On Wed, Mar 7, 2012 at 3:09 PM, Andy Colson a...@squeakycode.net wrote:
Took me a while to figure this out, thought I'd paste it here for others to
use:
create or replace function round_timestamp(timestamp, integer) returns
timestamp as $$
select date_trunc('minute', $1) +