interval to seconds conversion. How?

Started by Denis Zaitsevover 21 years ago7 messagesgeneral
Jump to latest
#1Denis Zaitsev
zzz@anda.ru

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.

#2Denis Zaitsev
zzz@anda.ru
In reply to: Denis Zaitsev (#1)
Re: interval to seconds conversion. How?

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).

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Denis Zaitsev (#1)
Re: interval to seconds conversion. How?

Denis Zaitsev <zzz@anda.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

#4Denis Zaitsev
zzz@anda.ru
In reply to: Tom Lane (#3)
Re: interval to seconds conversion. How?

On Wed, Oct 27, 2004 at 06:30:24PM -0400, Tom Lane wrote:

Denis Zaitsev <zzz@anda.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.

#5Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Denis Zaitsev (#1)
Re: interval to seconds conversion. How?

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)

#6Robby Russell
robby@planetargon.com
In reply to: Denis Zaitsev (#1)
Re: interval to seconds conversion. How?

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@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now supporting PHP5 and PHP4 ---
****************************************/

#7Michael Fuhr
mike@fuhr.org
In reply to: Denis Zaitsev (#1)
Re: interval to seconds conversion. How?

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/