Re: time interval math

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: time interval math
Date: 2012-02-09 01:51:10
Message-ID: m3d39oixkh.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Edward W. Rouse" <erouse(at)comsquared(dot)com> wrote:

> Hehe, thanks, I played around and ended up with this:

> round(SUM(extract('epoch' from (time_out - time_in))))

> I will have to do the division outside of the query, but that's really a
> minor issue.

You can always use subqueries.

> Knowing the total in seconds was the big roadblock. And
> converting back is easier (a / 3600 + ":" + a / 60 + ":" + a % 60)
> [...]

PostgreSQL has also:

| tim=# SELECT 3661::TEXT::INTERVAL;
| interval
| ----------
| 01:01:01
| (1 Zeile)

| tim=#

Tim

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message ssylla 2012-02-09 01:58:05 update column
Previous Message Edward W. Rouse 2012-02-08 20:49:32 Re: time interval math