Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 89FAB9FB321 for ; Wed, 7 Feb 2007 13:22:32 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 99236-02-3 for ; Wed, 7 Feb 2007 13:22:28 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtp10.kymp.net (smtp10.kymp.net [80.248.96.136]) by postgresql.org (Postfix) with ESMTP id 07C129FB39B for ; Wed, 7 Feb 2007 13:03:37 -0400 (AST) Received: from kymifedora (static-241-66.kymp.net [213.130.241.66]) by smtp10.kymp.net (8.13.6/8.13.3) with SMTP id l17H3Z9a001686 for ; Wed, 7 Feb 2007 19:03:35 +0200 From: Aarni =?iso-8859-1?q?Ruuhim=E4ki?= Reply-To: aarni@kymi.com Organization: KYMI.com To: pgsql-sql@postgresql.org Subject: interval as hours or minutes ? Date: Wed, 7 Feb 2007 19:03:35 +0200 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200702071903.35126.aarni@kymi.com> X-Virus-Scanned: by amavisd-new X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL, BAYES_50 X-Spam-Level: X-Archive-Number: 200702/60 X-Sequence-Number: 27394 Hi all, Could anyone please tell an easy way to get total hours or minutes from an= =20 interval ? SELECT SUM(stop_date_time - start_date_time) AS tot_time FROM work_times WH= ERE=20 user_id =3D 1; tot_time =2D---------------- 2 days 14:08:44 I'd like to have this like ... AS tot_hours ... tot_hours =2D---------------- 62 and ... AS tot_minutes ... tot_minutes =2D---------------- 3728 Maybe even ... AS tot_hours_minutes_seconds tot_hours_minutes_seconds =2D---------------- 62:08:44 start_date_time and stop_date_time are stored as timestamp without time zon= e,=20 using Pg 8.1.5 on CentOs 4.4 ??? Thanks, =2D-=20 Aarni Ruuhim=E4ki