X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D4F343A202A for ; Fri, 31 Dec 2004 19:44:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54365-07 for ; Fri, 31 Dec 2004 19:44:02 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id D64AE3A1D07 for ; Fri, 31 Dec 2004 19:41:28 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iBVJfMoC034766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 31 Dec 2004 12:41:25 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iBVJfMgC024062; Fri, 31 Dec 2004 12:41:22 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iBVJfIjQ024061; Fri, 31 Dec 2004 12:41:18 -0700 (MST) (envelope-from mfuhr) Date: Fri, 31 Dec 2004 12:41:18 -0700 From: Michael Fuhr To: Jamison Roberts Cc: pgsql-sql@postgresql.org Subject: Re: Formatting an Interval Message-ID: <20041231194118.GA23987@winnie.fuhr.org> References: <238e52230412310837183fb730@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <238e52230412310837183fb730@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200412/168 X-Sequence-Number: 19788 On Fri, Dec 31, 2004 at 11:37:32AM -0500, Jamison Roberts wrote: > All of the functions that i've looked at seem to only extract parts > from Intervals. What I need to do is to format the interval. For > instance, I have a Interval with the value 1 day 07:57:52. I would > like that in HH:MM:SS. So in the example the output would be > 31:57:52. I'm not aware of a built-in way to get such a format; somebody please correct me if I'm mistaken. You could write a function to format the interval. For example, with PL/pgSQL you could use EXTRACT(epoch FROM interval_value) to convert the interval to a number of seconds; convert that to hours, minutes, and seconds; and use TO_CHAR to format the return value. -- Michael Fuhr http://www.fuhr.org/~mfuhr/