From: George Moga <george@flex.ro>
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
To: SQL PostgreSQL <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] time intervals
Date: Fri, 30 Apr 1999 12:53:13 +0300
Message-ID: <37297D89.1B186907@flex.ro> (raw)
References: <01BE925B.352BE160.jt-kirkpatrick@mpsllc.com>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
JT Kirkpatrick wrote:
<blockquote TYPE=CITE>I have two fields, timein & timeout, both defined
as type "time". how can
<br>i get the difference between the two?? i am connecting to postgres
through
<br>access97 and trying to run a simple query to show me timeout, timein,
and
<br>timeout-timein, but the calculation is returning an error.
<p>thanks in advance! jt</blockquote>
<p><br>If your field is defined by tipe "time", the date is not important.
<p>In this case you can use the age(datetime, datetime) in this mode:
<p><tt>a. timein < timeout:</tt><tt></tt>
<p><tt>test=> select age(datetime('today'::date,'10:00:15'::time), datetime('today'::date,'12:25:24'::time));</tt>
<br><tt>age</tt>
<br><tt>----------------------------</tt>
<br><tt>@ 2 hours 25 mins 9 secs ago</tt>
<br><tt>(1 row)</tt>
<p>or
<p><tt>b. timein > timeout:</tt>
<br><tt>test=> select age(datetime('today'::date,'10:00:15'::time), datetime('today'::date,'2:25:24'::time));</tt>
<br><tt>age</tt>
<br><tt>-------------------------</tt>
<br><tt>@ 7 hours 34 mins 51 secs</tt>
<br>(1 row)
<br>
<p>I use PostgreSQL v6.5.0 (09-04-1999) on Red Hat LINUX 5.2 with
2.2.5 kernel.
<br>-- <br>
Best,<br>
George Moga,<br>
george@flex.ro<br>
Braila,ROMANIA
<br> </html>
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: george@flex.ro, jt-kirkpatrick@mpsllc.com
Subject: Re: [SQL] time intervals
In-Reply-To: <37297D89.1B186907@flex.ro>
* 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