PG Bug reporting form <noreply@postgresql.org> writes:
> While casting intervals to time I noticed interval '24h' casts to '00:00:00'
> time rather than '24:00:00'
> Casting first to text or varchar then to time works as expected
> select (interval '24h')::time; => '00:00:00'
> select (interval '24h')::text::time => '24:00:00';
> I experienced this in PostgreSQL 9 -12 .
> Is this a bug or is this how it is supposed to work?
Interval-to-time casts take the interval modulo 24 hours, so I'd
say this is expected.
regression=# select '40:00:01'::interval::time;
time
----------
16:00:01
(1 row)
Note that time itself would refuse to store a value larger than 24hr.
regards, tom lane