0
select '06:00:00'::TIME - ('19:00:00'::TIME - '07:00:23.388471'::TIME);
+-----------------+
| ?column?        |
|-----------------|
| 18:00:23.388471 |
+-----------------+
SELECT 1
Time: 0.012s

Why isn't it returning a negative result? I'm using the latest version of PostgreSQL.

2
  • Yo u are substracting from a time value ('06:00:00') an interval (the result of ('19:00:00'::TIME - '07:00:23.388471'::TIME)). The result of time - interval is a time value. And time values are only between '00:00:00' and '24:00:00' Commented Apr 1, 2022 at 23:51
  • Try for example: select '06:00:00'::TIME, '06:00:00'::TIME + interval '24 hour', '06:00:00'::TIME - interval '24 hour' ;. You'll get three identical values. Commented Apr 1, 2022 at 23:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.