Re: How to store in hours:minutes:seconds where hours may be bigger than 24

From: Celia McInnis <celia(dot)mcinnis(at)gmail(dot)com>
To: Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to store in hours:minutes:seconds where hours may be bigger than 24
Date: 2024-03-20 02:56:34
Message-ID: CAGD6t7KjZMEKaLYZtcKNjhfDk--GB1M+B_jEUmknhtnB1HTsKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the suggestion, Steve, but No - when I insert 25:17:07::interval
into my table I get 01:17:07 into the table - i.e., it replaces 25 hours by
(25 mod 24) hours or 1 hour, and this is not what I want. I really need the
number of hours rather than the number of hours mod 24. Do I have to make a
composite type to get what I want???

Thanks,
Celia McInnis

On Tue, Mar 19, 2024 at 10:44 PM Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>
wrote:

> 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(dot)mcinnis(at)gmail(dot)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
>>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2024-03-20 03:01:27 Re: How to store in hours:minutes:seconds where hours may be bigger than 24
Previous Message Steve Baldwin 2024-03-20 02:44:13 Re: How to store in hours:minutes:seconds where hours may be bigger than 24