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: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>, "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 03:07:12
Message-ID: CAGD6t7LE4YbE24pdZAwAdCNXP6mo-H5HOJdB=QMZoMEBXB6-mw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Whoops - I hadn't changed the type of the column in the table that I was
inserting into - it was of type "TIME WITHOUT TIMEZONE". Now that I have
set the column type to INTERVAL, I can insert the string '25:17:07' into
the column without even needing to do any casting.

Thank goodness and thanks!
Celia

On Tue, Mar 19, 2024 at 11:01 PM Christophe Pettus <xof(at)thebuild(dot)com> wrote:

>
>
> > On Mar 19, 2024, at 19:56, Celia McInnis <celia(dot)mcinnis(at)gmail(dot)com>
> wrote:
> >
> > 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???
>
> I'm not seeing that result:
>
> xof=# create table t (i interval);
> CREATE TABLE
> xof=# insert into t values('25:17:07'::interval);
> INSERT 0 1
> xof=# select * from t;
> i
> ----------
> 25:17:07
> (1 row)
>
> Can you show what you are doing that gets the result you describe?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mark bradley 2024-03-20 13:26:29 SSL error on install of PEM during Posgres install
Previous Message Tom Lane 2024-03-20 03:02:49 Re: How to store in hours:minutes:seconds where hours may be bigger than 24