Thread: Retrieving INTERVAL as float hours?

Retrieving INTERVAL as float hours?

From
Ken Causey
Date:
This may be a stupid question, and feel free to RTFM me, but please
specify the manual/book as I can't seem to find this.  I want
to retrieve an INTERVAL (the sum of INTERVALS actually) as a float
hour.  In other words if I normally get an output like

@ 2 hours 30 minutes

I would like

2.5

Thanks in advance for all help.

Ken Causey


Re: Retrieving INTERVAL as float hours?

From
"Alex Bolenok"
Date:
----- Original Message -----
From: "Ken Causey" <ken@premiernet.net>
To: <pgsql-general@postgresql.org>
Sent: Wednesday, July 12, 2000 6:14 PM
Subject: [GENERAL] Retrieving INTERVAL as float hours?


> This may be a stupid question, and feel free to RTFM me, but please
> specify the manual/book as I can't seem to find this.  I want
> to retrieve an INTERVAL (the sum of INTERVALS actually) as a float
> hour.  In other words if I normally get an output like
>
> @ 2 hours 30 minutes
>
> I would like
>
> 2.5
>
> Thanks in advance for all help.
>
> Ken Causey
>
>

ikar=# SELECT DATE_PART('epoch', '2 hours 30 minutes'::interval) / 3600;
 ?column?
----------
      2.5
(1 row)

Alex Bolenok