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 4D3A0D1B459 for ; Mon, 7 Jun 2004 04:52:11 -0300 (ADT) 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 15896-10 for ; Mon, 7 Jun 2004 07:52:08 +0000 (GMT) Received: from ara.zf.jcu.cz (ara.zf.jcu.cz [160.217.161.4]) by svr1.postgresql.org (Postfix) with ESMTP id 063B1D1B3B6 for ; Mon, 7 Jun 2004 04:52:01 -0300 (ADT) Received: from ara.zf.jcu.cz (localhost [127.0.0.1]) by nod32.zf.jcu.cz (Postfix) with ESMTP id F18D5982F; Mon, 7 Jun 2004 09:52:00 +0200 (CEST) X-Virus-Scanner: This message was checked by NOD32 Antivirus system NOD32 for Linux Mail Server. For more information on NOD32 Antivirus System, please, visit our website: http://www.nod32.com/ Received: by ara.zf.jcu.cz (Postfix, from userid 5770) id DE9CF9835; Mon, 7 Jun 2004 09:52:00 +0200 (CEST) Date: Mon, 7 Jun 2004 09:52:00 +0200 From: Karel Zak To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: Formatting problems with negative intervals, TO_CHAR Message-ID: <20040607075200.GA28529@zf.jcu.cz> References: <13d849b7ee63de04179c102cb25159d2@news.teranews.com> <21474.1086561656@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21474.1086561656@sss.pgh.pa.us> User-Agent: Mutt/1.3.28i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/50 X-Sequence-Number: 17995 On Sun, Jun 06, 2004 at 06:40:56PM -0400, Tom Lane wrote: > Jeff Boes writes: > > This seems ... well, counter-intuitive at least: > > (using Pg 7.4.1) > > > # select to_char('4 minutes'::interval - > > '5 minutes 30 seconds'::interval, 'mi:ss'); > > > to_char > > --------- > > -1:-3 > > (1 row) > > > Why is the trailing zero lost? Why are there two minus signs? > > > I would expect '-1:30'. > > Yeah, me too. The underlying interval value seems right: > > regression=# select '4 minutes'::interval - '5 minutes 30 seconds'::interval; > ?column? > ----------- > -00:01:30 > (1 row) > > so I think this is a to_char() bug. Possibly it's platform-dependent > --- the roundoff behavior for division with a negative input varies > across machines. However I do see the bug on HPUX 10.20 with CVS tip. Please, read PostgreSQL docs. http://www.postgresql.org/docs/7.4/static/functions-formatting.html Warning: to_char(interval, text) is deprecated and should not be used in newly-written code. It will be removed in the next version. Karel -- Karel Zak http://home.zf.jcu.cz/~zakkr/