pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Terry Lee Tucker <terry@esc1.com>
To: pgsql-sql@postgresql.org
Subject: Re: Simple Question
Date: Tue, 11 Jan 2005 17:21:25 -0500
Message-ID: <200501111721.25497.terry@esc1.com> (raw)
In-Reply-To: <1105481194.5382.18.camel@sigurd.incentre.net>
References: <200501111642.21716.terry@esc1.com>
	<1105481194.5382.18.camel@sigurd.incentre.net>

Thanks for the reply. My answer was a little different than yours because I 
used 488 instead of 478. Well, that three ways so far ;o)

On Tuesday 11 January 2005 05:06 pm, Guy Fraser saith:
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend

 Work: 1-336-372-6812
 Cell: 1-336-363-4719
email: terry@esc1.com



view thread (15+ messages)  latest in thread

Message-ID: <200501111721.25497.terry@esc1.com>
Permalink:  ../200501111721.25497.terry@esc1.com/
Also on:    postgresql.org/message-id/200501111721.25497.terry@esc1.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: terry@esc1.com
  Subject: Re: Simple Question
  In-Reply-To: <200501111721.25497.terry@esc1.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox