Lists: | pgsql-bugs |
---|
From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | iomihai(at)hotmail(dot)com |
Subject: | BUG #16338: casting interval '24h' to time returns '00:00:00' instead of '24:00:00' |
Date: | 2020-04-02 15:55:18 |
Message-ID: | 16338-b198c8cc2395ba5f@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 16338
Logged by: Io Mihai
Email address: iomihai(at)hotmail(dot)com
PostgreSQL version: 12.2
Operating system: Arch Linux, Ubntu
Description:
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?
Thank you,
Mihai
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | iomihai(at)hotmail(dot)com |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #16338: casting interval '24h' to time returns '00:00:00' instead of '24:00:00' |
Date: | 2020-04-02 16:05:59 |
Message-ID: | 18560.1585843559@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
PG Bug reporting form <noreply(at)postgresql(dot)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