Search Postgresql Archives

Re: Convert interval to hours

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/14/2018 11:10 AM, Steven Lembark wrote:
On Fri, 14 Sep 2018 11:55:18 -0400
Peter Kleiner <runtfan71@xxxxxxxxx> wrote:
On Fri, Sep 14, 2018 at 11:51 AM David Gauthier
<davegauthierpg@xxxxxxxxx> wrote:
Hi:

In perl/DBI, I have code that's getting me an "age" which returns
something like... "-17 days -08:29:35".  How can I convert that to
a number of hours (as a float I would presume) ?
Suggest using one of the date modules. One issue is that not all
days are 86400s long: "leap second" is used to keep atomic clocks
in sync with siderial time so that telescopes report consistent
values over time. Catch is that simply dividing by 3600 doesn't
always work if the times fall across the wrong days.

Can you give us a hard example of when this won't work?

select extract(epoch from '-17 days -08:29:35'::interval)/3600 as hours;

hours
-------------------
 -416.493055555556
(1 row)


--
Angular momentum makes the world go 'round.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux