pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Convert interval to hours
Date: Fri, 14 Sep 2018 12:24:22 -0500
Message-ID: <784823d5-c1f8-590f-946e-f0040ac64278@gmail.com> (raw)
In-Reply-To: <20180914111050.16b7af88@steamer.attlocal.net>
References: <CAMBRECASE0aEf28DTVpY58MDrZVP9nUcTPW7NJkwPv4uVk-oAw@mail.gmail.com>
	<CAP8Hi7Kt=r-pQbq5fnr-e029aLfX=ppyu+6mySxz_oe86LrMnA@mail.gmail.com>
	<20180914111050.16b7af88@steamer.attlocal.net>

On 09/14/2018 11:10 AM, Steven Lembark wrote:
> On Fri, 14 Sep 2018 11:55:18 -0400
> Peter Kleiner <runtfan71@gmail.com> wrote:
>> On Fri, Sep 14, 2018 at 11:51 AM David Gauthier
>> <davegauthierpg@gmail.com> 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.




view thread (6+ messages)  latest in thread

Message-ID: <784823d5-c1f8-590f-946e-f0040ac64278@gmail.com>
Permalink:  ../784823d5-c1f8-590f-946e-f0040ac64278@gmail.com/
Also on:    postgresql.org/message-id/784823d5-c1f8-590f-946e-f0040ac64278@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: Convert interval to hours
  In-Reply-To: <784823d5-c1f8-590f-946e-f0040ac64278@gmail.com>
  References: <CAMBRECASE0aEf28DTVpY58MDrZVP9nUcTPW7NJkwPv4uVk-oAw@mail.gmail.com> <CAP8Hi7Kt=r-pQbq5fnr-e029aLfX=ppyu+6mySxz_oe86LrMnA@mail.gmail.com> <20180914111050.16b7af88@steamer.attlocal.net> <784823d5-c1f8-590f-946e-f0040ac64278@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox