X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 89D5F3A5AC6 for ; Tue, 11 Jan 2005 22:07:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88314-03 for ; Tue, 11 Jan 2005 22:07:09 +0000 (GMT) Received: from bach.ccinet.ab.ca (bach.ccinet.ab.ca [198.161.96.1]) by svr1.postgresql.org (Postfix) with ESMTP id B63323A5ACE for ; Tue, 11 Jan 2005 22:07:07 +0000 (GMT) Received: from guy-pc.incentre.net (guy-pc.incentre.net [206.75.213.195] (may be forged)) by bach.ccinet.ab.ca (8.12.9p2/8.12.9) with ESMTP id j0BM6oLQ049984; Tue, 11 Jan 2005 15:06:50 -0700 (MST) (envelope-from guy@incentre.net) Subject: Re: Simple Question From: Guy Fraser Reply-To: guy@incentre.net To: Terry Lee Tucker Cc: pgsql-sql@postgresql.org In-Reply-To: <200501111642.21716.terry@esc1.com> References: <200501111642.21716.terry@esc1.com> Content-Type: text/plain Organization: The Internet Centre Date: Tue, 11 Jan 2005 15:06:34 -0700 Message-Id: <1105481194.5382.18.camel@sigurd.incentre.net> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.315 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/44 X-Sequence-Number: 19832 Convert to seconds first (3600 sec/hr) : select ( '3600'::int4 * '478'::int4 / '45.0'::float8 )::int4::reltime::interval ; interval ---------- 10:37:20 (1 row) I don't know if "::int4::reltime::interval" is the best way to end up with an interval, but its the only way I could figure out how to do it off the top of my head. On Tue, 2005-11-01 at 16:42 -0500, Terry Lee Tucker wrote: > Hello: > > I'm trying to figure out how to convert a floating point value into an > interval of time. I'm calculating the time required to drive from point A to > point B. For the sake of this question, we'll just say it is miles/speed. So: > > drv_time = 478 / 45.0; > > The value of this is: 10.6222222222222222 > > Is there a way of converting this value to an interval. It seems that INTERVAL > only works with a quoted literal value. > > If I type: > rnd=# select interval '10.8444444444444444 hours'; > interval > ---------------------------- > @ 10 hours 50 mins 40 secs > (1 row) > > Anybody have an pointers? > > Thanks... > > > Work: 1-336-372-6812 > Cell: 1-336-363-4719 > email: terry@esc1.com > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- Guy Fraser Network Administrator The Internet Centre 1-888-450-6787 (780)450-6787