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 23D17D1B1EC for ; Fri, 4 Jun 2004 22:17:35 -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 19500-05 for ; Sat, 5 Jun 2004 01:17:34 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 2A3EBD1B16F for ; Fri, 4 Jun 2004 22:17:30 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i551HTDW012009 for ; Sat, 5 Jun 2004 01:17:29 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i5510Tbq008046 for pgsql-sql@postgresql.org; Sat, 5 Jun 2004 01:00:29 GMT X-Abuse-Report: abuse@teranews.com Message-ID: <13d849b7ee63de04179c102cb25159d2@news.teranews.com> Date: Thu, 03 Jun 2004 20:03:17 GMT Lines: 45 From: Jeff Boes User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql.sql Subject: Formatting problems with negative intervals, TO_CHAR Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit To: pgsql-sql@postgresql.org 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/44 X-Sequence-Number: 17989 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'. Likewise, # select to_char('4 minutes'::interval - '4 minutes 30 seconds'::interval, # 'mi:ss'); to_char --------- 00:-3 (1 row) I would expect '-00:30'. I ended up fixing this with a very convoluted expression: ... case when last.time_count > prev.time_count then '+' else '-' end || to_char((abs(extract(epoch from last.time_count) - extract(epoch from prev.time_count)) || 'seconds')::interval,'FMmi:ss.cc') but I have to believe there is an easier way. -- (Posted from an account used as a SPAM dump. If you really want to get in touch with me, dump the 'jboes' and substitute 'mur'.) ________ Jeffery Boes <>< jboes@qtm.net