pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16338: casting interval '24h' to time returns '00:00:00' instead of '24:00:00'
2+ messages / 2 participants
[nested] [flat]

* BUG #16338: casting interval '24h' to time returns '00:00:00' instead of '24:00:00'
@ 2020-04-02 15:55  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2020-04-02 15:55 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: iomihai@hotmail.com

The following bug has been logged on the website:

Bug reference:      16338
Logged by:          Io Mihai
Email address:      iomihai@hotmail.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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16338: casting interval '24h' to time returns '00:00:00' instead of '24:00:00'
@ 2020-04-02 16:05  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2020-04-02 16:05 UTC (permalink / raw)
  To: iomihai@hotmail.com; +Cc: pgsql-bugs@lists.postgresql.org

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-04-02 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 15:55 BUG #16338: casting interval '24h' to time returns '00:00:00' instead of '24:00:00' PG Bug reporting form <noreply@postgresql.org>
2020-04-02 16:05 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox