Search Postgresql Archives

Regarding interval conversion functions and a seeming lack of usefulness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxxxx
Phone: 412-422-3463x4023

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux