X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 98C2147580B for ; Mon, 12 May 2003 13:13:50 -0400 (EDT) Received: from mx-a.qnet.com (mx-a.qnet.com [209.221.198.11]) by postgresql.org (Postfix) with ESMTP id 40AAA474E42 for ; Mon, 12 May 2003 13:13:49 -0400 (EDT) Received: from cello.qnet.com (root@cello.qnet.com [209.221.198.10]) by mx-a.qnet.com (8.12.9/8.12.9) with ESMTP id h4CHDaBr018127 for ; Mon, 12 May 2003 10:13:36 -0700 (PDT) Received: from cello.qnet.com (cello.qnet.com [209.221.198.10]) by cello.qnet.com (8.9.3/8.9.1) with ESMTP id KAA24436 for ; Mon, 12 May 2003 10:13:32 -0700 (PDT) Date: Mon, 12 May 2003 10:13:32 -0700 (PDT) From: Chris Linstruth To: Subject: Re: epoch to timestamp In-Reply-To: <114710000.1052755333@lerlaptop.iadfw.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/223 X-Sequence-Number: 13388 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 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 > 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 :-) ) > > > >