This has come up a few times over the last few months, and I'm not
too keen on the solutions we've been using.
There seems to be a lack of useful functions for converting intervals
to useful representations. For example, I want to display an interval
in hours and fractions of hours only, not hours and minutes. There
are lots of examples of when certain representations are more appropriate
than others (think pregnancy terms, why on earth is the woman never
pregnant for 3 months? It's always 12 weeks!)
Anyway, rant aside, I can't seem to find anything to do this in PG.
I could write a stored procedure easily enough, but I want to make
sure I'm not reinventing the wheel first (I find it hard to believe
I'm the first person ever wanting to do this!)
Something like:
$ SELECT CONVERT('12 days 13 hours'::INTERVAL AS hour);
hour
------
301
$ SELECT CONVERT('6 hours 17 minutes'::INTERVAL AS hour);
hour
------
6.2833
Am I approaching this problem wrong? or is there something out there
and my Google skills are lacking?
--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/
wmoran@collaborativefusion.com
Phone: 412-422-3463x4023