X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5BC274763AC for ; Fri, 2 May 2003 19:12:05 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 04E02476463 for ; Fri, 2 May 2003 19:11:55 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id B697ED643; Fri, 2 May 2003 16:11:57 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id AC46B5C0B; Fri, 2 May 2003 16:11:57 -0700 (PDT) Date: Fri, 2 May 2003 16:11:57 -0700 (PDT) From: Stephan Szabo To: Katka a Daniel Dunajsky Cc: Subject: Re: Time formating In-Reply-To: Message-ID: <20030502160941.K77930-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-25.2 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES 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/40 X-Sequence-Number: 13205 On Fri, 2 May 2003, Katka a Daniel Dunajsky wrote: > Hello All, > > This question is related to my preceeding question. > > How to format a value 7383 to represent 02H:03M:03SS (hours-minutes-seconds) > using postgresql? > > I have this query: > > SELECT SUM (session_length))/60)/60 AS "Total", > FROM user_sessions > WHERE TO_CHAR(session_start, 'YYYY-MM') = '2003-04'; > > If session_length = 7383 I will receive 2. A better way would probably be something like: SELECT INTERVAL '1 second' * session_length AS "Total" ... > I have received advice that I should use . and it will work with > > select 5./2, however how to do it when I have a variable? Use a cast of the general form CAST( as ).