Search Postgresql Archives

Re: More straight forward method to convert seconds::bigint to interval

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

 



Shane R. Spencer wrote:
I work in VoIP.  HMS (Hour/Minute/Second) format appears to be the rule
when working with call time totals.  I admit it makes some reports
easier to read.

The method I used to convert a int/bigint to HMS (or the standard
representation of an interval type) is as follows:

select (123456.789::varchar(24) || ' seconds')::interval as HMS;
     hms
--------------
 34:17:36.789

Is there a less string oriented method of converting seconds as an int
to an interval?

- Shane


I think this is cleaner/faster:


select interval '1 second' * 123456.789 as HMS;

     hms
--------------
 34:17:36.789


-Adam




--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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