Skip to content
Advertisement

More than 24 hours in a day in postgreSQL

Assuming I have this schema:

Running this query returns strange results:

It displays:

Why is there values like 5 days 34:58:38, 5 days 32:56:32 and so on? I thought there where only 24 hours in a day, maybe I’m wrong.

EDIT

Demo here: http://sqlfiddle.com/#!17/caa7a/1/0

Sample data:

Advertisement

Answer

You have to adjust interval with justify_interval() function:

See official doc:

Adjust interval using justify_days and justify_hours, with additional sign adjustments

Still, it does not explains why the result of the operation is that weird without using justify_interval() (in other words, why we have to apply this function)

Note: thanks to @a_horse_with_no_name for their comment

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement