calculating elapsed times between timestamps

From: rhubbell <Rhubbell(at)iHubbell(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: calculating elapsed times between timestamps
Date: 2009-02-02 19:50:38
Message-ID: 20090202115038.66315062.Rhubbell@iHubbell.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Just found this novice list. pgsql seems to have very specific lists...

I have been trying to do this and have been unsuccessful so far.

I have a table:

perf:
timestamp = timestamp with time zone
timeelapsed = numeric
bobble = text

timeelapsed records are the time elapsed metric in seconds.

e.g. 0.350058078765869

Typical scenario is that I'll have multiple entries where timeelapsed
is greater than some value and will be greater than that value for
some time interval.

I want to find the length of those intervals.

select timestamp, timeelapsed, bobble from perf where bobble like "pokerflat"
and timeelapsed > 0.4;

The records returned by that query will have an oldest and newest timestamp for
which I would like to calculate the interval.

I found lots of examples of doing arithmetic on timestamps but I never saw
any extracting data from a table. All the examples I found were using now()
or today + 3 or the like.

Browse pgsql-novice by date

  From Date Subject
Next Message Nikhil teltia 2009-02-02 23:35:52 Function Returning a Set of Composite Value
Previous Message ries van Twisk 2009-02-02 19:20:43 Re: [NOVICE] LATIN2->UTF8 conversation with dblink