Re: epoch to timestamp

From: Chris Linstruth <cjl(at)QNET(dot)COM>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: epoch to timestamp
Date: 2003-05-12 17:13:32
Message-ID: Pine.BSI.4.33.0305121004230.8437-100000@cello.qnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

I wanted an interval to be displayed as HH:MI:SS even when the
number of hours is greater than 24. I resorted to something like
this:

acctsessiontime is an interval.

SELECT
date_part('seconds', acctsessiontime) as connectseconds,
date_part('minutes, acctsessiontime) as connectminutes,
date_part('hours', acctsessiontime) as connecthours,
date_part('days', acctsessiontime) as connectdays
....

I then did the old connecthours += connectdays * 24 routine.

Is there some sort of inverse "date_trunc" that would enable me
to say: to_char(acctsessiontime, 'HH:MI:SS') and get, for example,
147:23:12?

--
Chris Linstruth <cjl(at)qnet(dot)com>
QNET
1529 East Palmdale Blvd Suite 200
Palmdale, CA 93550
(661) 538-2028

On Mon, 12 May 2003, Larry Rosenman wrote:

>
>
> --On Monday, May 12, 2003 09:00:11 -0700 Josh Berkus <josh(at)agliodbs(dot)com>
> wrote:
>
> > Larry,
> >
> >> I actually have just seconds (from my LD carrier), and want to store it
> >> in hours/minutes/seconds.
> >
> > If you store it as an interval, you will end up with:
> >
> > staffos=# select '12742329 seconds'::INTERVAL;
> > interval
> > -------------------
> > 147 days 11:32:09
> >
> > In fact, you can't avoid interval conversion to days, hours, minutes.
> Yeah, I remembered that after I hit send (so, what else is new? /me
> looking like
> a dummy :-) )
>
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2003-05-12 17:23:54 Re: Caching Websites
Previous Message Adam Sherman 2003-05-12 17:01:40 Re: Performance Problem

Browse pgsql-sql by date

  From Date Subject
Next Message Katka a Daniel Dunajsky 2003-05-12 17:55:57 Why this query does not work?
Previous Message Larry Rosenman 2003-05-12 16:02:13 Re: epoch to timestamp