Re: Converting time interval to double precision of time unit

From: Mike Toews <mwtoews(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>, pgsql-general(at)postgresql(dot)org
Subject: Re: Converting time interval to double precision of time unit
Date: 2010-03-30 19:36:07
Message-ID: 22f0a52d1003301236y189f0ba2y46091f657eec4cb1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 30 March 2010 11:55, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I think what Mike is actually looking for is
>
> SELECT extract(epoch from interval '3 days 2 hours 34 minutes');
>  date_part
> -----------
>    268440

Yet better, if I define 1 hour as 3600 seconds (this is only incorrect
if the interval spans over a leap second), then the fractional hours
are:

SELECT extract(epoch from interval '3 days 2 hours 34 minutes')/3600 as hours;

Thanks!

-Mike

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Gage 2010-03-30 19:57:45 Running Windows on a Mac partition
Previous Message Tom Lane 2010-03-30 18:55:26 Re: Converting time interval to double precision of time unit