Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QUESTION ON INTERVALS CONVERSION TO INT

Status
Not open for further replies.

splendided

IS-IT--Management
Aug 29, 2002
2
0
0
GB

I have 2 interval values and I need to determine the percentage of one in relation to the other. As a first thought I would expect to cast the intervals to integers and calculate the percentage...

This is what I want to do in theory

eg

('00:15:00'::interval)::integer
/
('00:30:00'::interval)::integer
* 100

I'm not able to do the conversion using casting which probably makes sense considering the storage differences etc but I am struggling to see a straightforward solution to the problem from the documentation.

I am using Postgres v8.0 and higher.

Ed
 
ce@[local]:5432 test=*# select extract(epoch from '1:20:30'::interval) / extract(epoch from '0:40:15'::interval);
?column?
----------
2
(1 row)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top