Jorge Godoy wrote:
> Hi!
>
>
> I am needing to convert from TIME type to floats and taking 1h as the
> unit, so what I'd like is something that would allow me doing operations
> like:
>
> SELECT '00:10:00'::TIME / '1:00:00'::TIME; -- Answer is: 0.16666666666666666667
But it doesn't make any sense to divide one time by another, does it?
Are you sure it's not intervals you want?
Anyway, try something like this:
SELECT extract(epoch from ('14:02:04'::time)) / extract(epoch from
('01:00:00'::time));
?column?
------------------
14.0344444444444
The "epoch" is in seconds (from midnight 1970-01-01 for timestamps) so
gives you the result you want.
--
Richard Huxton
Archonet Ltd