Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group