interval to seconds conversion. How?

Lists: pgsql-general
From: Denis Zaitsev <zzz(at)anda(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: interval to seconds conversion. How?
Date: 2004-10-27 22:08:53
Message-ID: 20041028040853.A16092@macacos.ward.six
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

How can I calculate the number of second in some interval? Neither
the secods part, nor the seconds after midnight... Just the full
quantity of the seconds. I haven't find any function.

Thanks in advance.


From: Denis Zaitsev <zzz(at)anda(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: interval to seconds conversion. How?
Date: 2004-10-27 22:23:40
Message-ID: 20041028042340.B16092@macacos.ward.six
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Oct 28, 2004 at 04:08:53AM +0600, Denis Zaitsev wrote:
> How can I calculate the number of second in some interval? Neither
> the secods part, nor the seconds after midnight... Just the full
> quantity of the seconds. I haven't find any function.
>
> Thanks in advance.

Oh, I'm sorry. This is extract(epoch from interval).


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Denis Zaitsev <zzz(at)anda(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: interval to seconds conversion. How?
Date: 2004-10-27 22:30:24
Message-ID: 25408.1098916224@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Denis Zaitsev <zzz(at)anda(dot)ru> writes:
> How can I calculate the number of second in some interval? Neither
> the secods part, nor the seconds after midnight... Just the full
> quantity of the seconds. I haven't find any function.

EXTRACT(EPOCH FROM interval_value)

regards, tom lane


From: Denis Zaitsev <zzz(at)anda(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: interval to seconds conversion. How?
Date: 2004-10-27 22:37:21
Message-ID: 20041028043720.A16380@macacos.ward.six
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Oct 27, 2004 at 06:30:24PM -0400, Tom Lane wrote:
> Denis Zaitsev <zzz(at)anda(dot)ru> writes:
> > How can I calculate the number of second in some interval? Neither
> > the secods part, nor the seconds after midnight... Just the full
> > quantity of the seconds. I haven't find any function.
>
> EXTRACT(EPOCH FROM interval_value)

Yes, I've already found it... :) Thanks anyway.


From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: interval to seconds conversion. How?
Date: 2004-10-27 22:39:05
Message-ID: 20041027223905.GA6293@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Oct 28, 2004 at 04:08:53AM +0600, Denis Zaitsev wrote:
> How can I calculate the number of second in some interval? Neither
> the secods part, nor the seconds after midnight... Just the full
> quantity of the seconds. I haven't find any function.

I think you can do that using

EXTRACT(epoch FROM interval-value)

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"The problem with the future is that it keeps turning into the present"
(Hobbes)


From: Robby Russell <robby(at)planetargon(dot)com>
To: Denis Zaitsev <zzz(at)anda(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: interval to seconds conversion. How?
Date: 2004-10-27 22:45:14
Message-ID: 1098917114.4435.39.camel@vacant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, 2004-10-28 at 04:08 +0600, Denis Zaitsev wrote:
> How can I calculate the number of second in some interval? Neither
> the secods part, nor the seconds after midnight... Just the full
> quantity of the seconds. I haven't find any function.
>
> Thanks in advance.
>

SELECT extract(epoch FROM n);

n = interval

-Robby

--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robby(at)planetargon(dot)com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now supporting PHP5 and PHP4 ---
****************************************/


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: interval to seconds conversion. How?
Date: 2004-10-27 22:52:28
Message-ID: 20041027225227.GA97676@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Oct 28, 2004 at 04:08:53AM +0600, Denis Zaitsev wrote:
> How can I calculate the number of second in some interval? Neither
> the secods part, nor the seconds after midnight... Just the full
> quantity of the seconds. I haven't find any function.

test=> SELECT extract(epoch FROM '5 hours 42 minutes 35 seconds'::INTERVAL);
date_part
-----------
20555

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/