From: Tom Lane <tgl@sss.pgh.pa.us>
To: Karel Zak <zakkr@zf.jcu.cz>
Cc: pgsql-sql@postgresql.org
Subject: Re: Formatting problems with negative intervals, TO_CHAR
Date: Sun, 06 Jun 2004 18:40:56 -0400
Message-ID: <21474.1086561656@sss.pgh.pa.us> (raw)
In-Reply-To: <13d849b7ee63de04179c102cb25159d2@news.teranews.com>
References: <13d849b7ee63de04179c102cb25159d2@news.teranews.com>
Jeff Boes <jboes@qtm.net> 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.
> Likewise,
> # select to_char('4 minutes'::interval -
> '4 minutes 30 seconds'::interval, 'mi:ss');
> to_char
> ---------
> 00:-3
> (1 row)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, zakkr@zf.jcu.cz
Subject: Re: Formatting problems with negative intervals, TO_CHAR
In-Reply-To: <21474.1086561656@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox