Re: Calculating with the time - Mailing list pgsql-sql

From Guy Fraser
Subject Re: Calculating with the time
Date
Msg-id 3ED7C97F.7020805@incentre.net
Whole thread Raw
In response to Calculating with the time  ("Katka a Daniel Dunajsky" <daniel_katka@hotmail.com>)
List pgsql-sql
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
>




pgsql-sql by date:

Previous
From: Ian Barwick
Date:
Subject: Re: Dynamic views/permissions
Next
From: "jtx"
Date:
Subject: join/case