pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guy Fraser <guy@incentre.net>
To: pgsql-sql@postgresql.org
Subject: Re: Calculating with the time
Date: Fri, 30 May 2003 15:13:35 -0600
Message-ID: <3ED7C97F.7020805@incentre.net> (raw)
References: <Law12-F35awhftgLeCR0002781b@hotmail.com>

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
>





view thread (2+ messages)

Message-ID: <3ED7C97F.7020805@incentre.net>
Permalink:  ../3ED7C97F.7020805@incentre.net/
Also on:    postgresql.org/message-id/3ED7C97F.7020805@incentre.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: guy@incentre.net
  Subject: Re: Calculating with the time
  In-Reply-To: <3ED7C97F.7020805@incentre.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox