Re: Formatting problems with negative intervals, TO_CHAR

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Formatting problems with negative intervals, TO_CHAR
Дата
Msg-id 21474.1086561656@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Formatting problems with negative intervals, TO_CHAR  (Jeff Boes <jboes@qtm.net>)
Ответы Re: Formatting problems with negative intervals, TO_CHAR
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: nzanella@cs.mun.ca (Neil Zanella)
Дата:
Сообщение: SQL DDL: FOREIGN KEY construct and field mapping: unexpected behavior
Следующее
От: Tom Lane
Дата:
Сообщение: Re: SQL DDL: FOREIGN KEY construct and field mapping: unexpected behavior