Thread: time calculations

time calculations

From
Oliver Vecernik
Date:
Hi,

I've got a table with two columns: one for distance in km (float4) and
one for the time (interval). I'd like to calculate the speed.

My problem is how to convert the intervals to decimal hours to be able
to a simple:

SELECT *, distance/time as speed from table;

Any clues? Are there any docs (maybe I have overseen something)?

Regards,
Oliver

Re: time calculations

From
Tom Lane
Date:
Oliver Vecernik <vecernik@aon.at> writes:
> My problem is how to convert the intervals to decimal hours

See date_part('epoch', interval_value)

            regards, tom lane