Search Postgresql Archives

Re: cast time interval to seconds

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

 



On Mon, Sep 10, 2007 at 08:44:07PM +0500, rihad wrote:
> Hi, I have two columns start_time & stop_time declared as "TIME". I'd 
> like to compute the difference between the two times in seconds, all in db:
> 
> SELECT
>   (CAST(stop_time AS SECONDS) + 86400 - CAST(start_time AS SECONDS))
>   % 86400;

At a guess I'd say you should simply subtract the two (ie stop_time -
start_time) and then use extract() to pull the seconds out.

Have a nice day,
-- 
Martijn van Oosterhout   <kleptog@xxxxxxxxx>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment: signature.asc
Description: Digital signature


[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