Re: Int to Interval conversion

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Howard Cole <howardnews(at)selestial(dot)com>
Subject: Re: Int to Interval conversion
Date: 2010-09-14 13:34:24
Message-ID: 201009140634.24357.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 14 September 2010 4:57:46 am Howard Cole wrote:
> Hi everyone,
>
> 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?
>
> Thanks.
>
> Howard Cole.

test=> SELECT 1440 * interval '1 min';
?column?
----------
24:00:00
(1 row)

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2010-09-14 13:41:12 Re: Int to Interval conversion
Previous Message Szymon Guz 2010-09-14 13:25:31 Re: Int to Interval conversion