Re: Int to Interval conversion

Поиск
Список
Период
Сортировка
От Bill Moran
Тема Re: Int to Interval conversion
Дата
Msg-id 20100914091408.ef97df3b.wmoran@potentialtech.com
обсуждение исходный текст
Ответ на Int to Interval conversion  (Howard Cole <howardnews@selestial.com>)
Список pgsql-general
In response to Howard Cole <howardnews@selestial.com>:
>
> I have a table with a duration field, stored as an Integer. How can I
> retrieve this from the table as an Interval type?
>
> E.g.
>
> create table test (test_id serial primary key, time_in_minutes int);
> insert into test values (1440);
>
> Now how do I extract that as 24:00:00::interval in a query?

SELECT CAST(time_in_minutes || ' minutes' AS INTERVAL) FROM test;

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

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

Предыдущее
От: Howard Cole
Дата:
Сообщение: Int to Interval conversion
Следующее
От: Szymon Guz
Дата:
Сообщение: Re: Int to Interval conversion