Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 92D9F19F5A50 for ; Wed, 8 Feb 2012 21:51:45 -0400 (AST) Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RvJAk-00057D-Gv for pgsql-sql@postgresql.org; Thu, 09 Feb 2012 01:51:44 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1RvJAU-0003un-Uz for pgsql-sql@postgresql.org; Thu, 09 Feb 2012 02:51:26 +0100 Received: from d223152.adsl.hansenet.de ([80.171.223.152]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Feb 2012 02:51:26 +0100 Received: from tim by d223152.adsl.hansenet.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Feb 2012 02:51:26 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Re: time interval math Date: Thu, 09 Feb 2012 01:51:10 +0000 Organization: Lines: 26 Message-ID: References: <032001cce69c$767bc010$63734030$@com> <4F32DA3B.9080209@pinpointresearch.com> <032701cce6a3$28c8fca0$7a5af5e0$@com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: d223152.adsl.hansenet.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:jKYBxYASW6exofT1KKiVl2UccPY= X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/26 X-Sequence-Number: 36319 "Edward W. Rouse" 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