Re: Aggregate time data on half hour interval

From: Kyle <kaf(at)nwlink(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Aggregate time data on half hour interval
Date: 2000-07-20 15:46:32
Message-ID: 14711.7896.848937.144298@ip146.usw5.rb1.bel.nwlink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If I wanted to aggregate a date field by week is the answer the same
or can date_trunc do that? A quick check implies no date_trunc...

-Kyle

Tom Lane wrote:
> Lars <lars(at)sscsinc(dot)com> writes:
> > What I would like to do though is aggregate by each half hour or maybe
> > even 20 minutes. Does anyone know a good way to do this?
>
> I don't have a *good* answer, but a brute-force way is
>
> * convert timestamp to integer seconds with date_part('epoch', foo)
> * round to a multiple of desired time interval
> * convert back to timestamp for display via timestamp()
>
> In the long run it seems like date_trunc ought to be more flexible
> than it is...
>
> regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mikeo 2000-07-20 15:48:36 Re: unique constraint - bug?
Previous Message Philip Warner 2000-07-20 15:35:29 Re: unique constraint - bug?