| From: | Ron <ronljohnsonjr(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Convert interval to hours |
| Date: | 2018-09-14 17:24:22 |
| Message-ID: | 784823d5-c1f8-590f-946e-f0040ac64278@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 09/14/2018 11:10 AM, Steven Lembark wrote:
> On Fri, 14 Sep 2018 11:55:18 -0400
> Peter Kleiner <runtfan71(at)gmail(dot)com> wrote:
>> On Fri, Sep 14, 2018 at 11:51 AM David Gauthier
>> <davegauthierpg(at)gmail(dot)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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dimitri Maziuk | 2018-09-14 17:31:48 | Re: Code of Conduct plan |
| Previous Message | Peter Geoghegan | 2018-09-14 17:14:38 | Re: Code of Conduct plan |