Mine does that as well. In fact, it doesn't even give the right answer. I
don't know if it's been fixed in a later version.
Very odd.
Welcome to psql 7.4.13, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
fc=> select to_char(age('2007-01-01 03:00','2007-01-01 04:59'),'HH24:MI');
to_char
---------
-1:-5
(1 row)
-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Frank Bax
Sent: 29 January 2007 02:31
To: pgsql-novice@postgresql.org
Subject: [NOVICE] 8.2.1 to_char(negative interval,'HH24:MI') bug?
select age('2007-01-01 03:00','2007-01-01 04:59');
age
-----------
-01:59:00
(1 row)
select to_char(age('2007-01-01 03:00','2007-01-01 04:59'),'HH24:MI');
to_char
---------
-1:-59
(1 row)
Isn't just one '-' enough? This leads to a problem here:
select '2007-01-03 06:00'::timestamp + age('2007-01-01 03:00','2007-01-01
04:59');
?column?
---------------------
2007-01-03 04:01:00
(1 row)
select '2007-01-03 06:00'::timestamp + to_char(age('2007-01-01
03:00','2007-01-01 04:59'),'HH24:MI')::interval;
?column?
---------------------
2007-01-03 05:00:00
(1 row)
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq