X-Original-To: pgsql-sql@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 12F6B925D9D for ; Fri, 30 May 2003 17:14:06 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 18372-01 for ; Fri, 30 May 2003 17:14:05 -0400 (EDT) Received: from bach.ccinet.ab.ca (bach.ccinet.ab.ca [198.161.96.1]) by developer.postgresql.org (Postfix) with ESMTP id C2E07925D8B for ; Fri, 30 May 2003 17:14:04 -0400 (EDT) Received: from incentre.net (squid.incentre.net [206.75.213.195]) by bach.ccinet.ab.ca (8.12.6/8.12.6) with ESMTP id h4ULGZMt069797 for ; Fri, 30 May 2003 15:16:35 -0600 (MDT) (envelope-from guy@incentre.net) Message-ID: <3ED7C97F.7020805@incentre.net> Date: Fri, 30 May 2003 15:13:35 -0600 From: Guy Fraser User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003 X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Calculating with the time References: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/581 X-Sequence-Number: 13746 Is this what you are looking for? test=# select 'now'::time as test,'2003-05-30 14:51:38-06'::timestamptz as stamp into temp cruft; SELECT test=# select test,stamp,test - stamp::time as diff from cruft; test | stamp | diff -----------------+------------------------+----------------- 15:09:28.862728 | 2003-05-30 14:51:38-06 | 00:17:50.862728 (1 row) test=# select test,stamp,reltime(test - stamp::time) as diff from cruft; test | stamp | diff -----------------+------------------------+---------- 15:09:28.862728 | 2003-05-30 14:51:38-06 | 00:17:50 (1 row) test=# drop table cruft; DROP TABLE Guy Katka a Daniel Dunajsky wrote: > Hello All, > > I am looking for an advice how to do calculation with the time. I do > have a column with datatype 'timestamp with time zone'. The value is > '2003-03-22 07:53:56-07' for instance. I would like to select it from > the table with result of '07:59:59' – '07:53:56', so the query should > return '00:06:03'. > > Thank you for your time. > > DanielD >