Re: How to store in hours:minutes:seconds where hours may be bigger than 24 - Mailing list pgsql-general

From Steve Baldwin
Subject Re: How to store in hours:minutes:seconds where hours may be bigger than 24
Date
Msg-id CAKE1AiYOQPaOGJcVX8KPzyYuHOb-FF6pPPFrRaJdO9-LFverkQ@mail.gmail.com
Whole thread Raw
In response to How to store in hours:minutes:seconds where hours may be bigger than 24  (Celia McInnis <celia.mcinnis@gmail.com>)
Responses Re: How to store in hours:minutes:seconds where hours may be bigger than 24
List pgsql-general
Could you use an interval data type? For example:

b2bcreditonline=# create table interval_example (i interval);
CREATE TABLE
b2bcreditonline=# insert into interval_example values ('26:15:32'::interval);
INSERT 0 1
b2bcreditonline=# select * from interval_example;
    i
----------
 26:15:32
(1 row)

b2bcreditonline=# select i, i + interval '45 minutes' as plus from interval_example;
    i     |   plus
----------+----------
 26:15:32 | 27:00:32
(1 row)

Steve

On Wed, Mar 20, 2024 at 1:05 PM Celia McInnis <celia.mcinnis@gmail.com> wrote:
Hi:

I want to store times in a database as hours:minutes:seconds where hours can be greater than 24. How do I do this? I will want to be able to add such times.

Thanks,
Celia McInnis

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: How to store in hours:minutes:seconds where hours may be bigger than 24
Next
From: Celia McInnis
Date:
Subject: Re: How to store in hours:minutes:seconds where hours may be bigger than 24