Re: Simple Question

Поиск
Список
Период
Сортировка
От Terry Lee Tucker
Тема Re: Simple Question
Дата
Msg-id 200501111707.28773.terry@esc1.com
обсуждение исходный текст
Ответ на Simple Question  (Terry Lee Tucker <terry@esc1.com>)
Список pgsql-sql
I figured it out. This works:

travel_window INTERVAL;
drv_time FLOAT;

drv_time = miles / 45.0;                -- drive time
travel_window = quote_literal(drv_time || '' hours'');

The variable, travel_window becomes:  @ 10 hours 50 mins 40 secs, which is 
what I wanted.

If anybody knows any other ways, I'd be interested in see that too.

On Tuesday 11 January 2005 04:42 pm, Terry Lee Tucker saith:
> 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
Work: 1-336-372-6812Cell: 1-336-363-4719
email: terry@esc1.com


В списке pgsql-sql по дате отправления:

Предыдущее
От: Guy Fraser
Дата:
Сообщение: Re: Simple Question
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Simple Question