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)