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




---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to