dbTalk Databases Forums  

interval to seconds conversion. How?

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss interval to seconds conversion. How? in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Denis Zaitsev
 
Posts: n/a

Default interval to seconds conversion. How? - 10-27-2004 , 05:08 PM






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.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #2  
Old   
Denis Zaitsev
 
Posts: n/a

Default Re: interval to seconds conversion. How? - 10-27-2004 , 05:23 PM






On Thu, Oct 28, 2004 at 04:08:53AM +0600, Denis Zaitsev wrote:
Quote:
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).

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: interval to seconds conversion. How? - 10-27-2004 , 05:30 PM



Denis Zaitsev <zzz (AT) anda (DOT) ru> writes:
Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
  #4  
Old   
Denis Zaitsev
 
Posts: n/a

Default Re: interval to seconds conversion. How? - 10-27-2004 , 05:37 PM



On Wed, Oct 27, 2004 at 06:30:24PM -0400, Tom Lane wrote:
Quote:
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.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
  #5  
Old   
Alvaro Herrera
 
Posts: n/a

Default Re: interval to seconds conversion. How? - 10-27-2004 , 05:39 PM



On Thu, Oct 28, 2004 at 04:08:53AM +0600, Denis Zaitsev wrote:
Quote:
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)


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #6  
Old   
Robby Russell
 
Posts: n/a

Default Re: interval to seconds conversion. How? - 10-27-2004 , 05:45 PM



On Thu, 2004-10-28 at 04:08 +0600, Denis Zaitsev wrote:
Quote:
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 ---
****************************************/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBBgCT60QaQZBaqXgwRAkqNAKC87oW/FxqFqxwliH3x86TIB1/zFACgv07v
2mHPFzhKbu4RuJBWpvRxW2E=
=ftX+
-----END PGP SIGNATURE-----



Reply With Quote
  #7  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: interval to seconds conversion. How? - 10-27-2004 , 05:52 PM



On Thu, Oct 28, 2004 at 04:08:53AM +0600, Denis Zaitsev wrote:
Quote:
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/

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.