Re: [SQL] time intervals

From: George Moga <george(at)flex(dot)ro>
To: JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com>, SQL PostgreSQL <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: [SQL] time intervals
Date: 1999-04-30 09:53:13
Message-ID: 37297D89.1B186907@flex.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
JT Kirkpatrick wrote:
<blockquote TYPE=CITE>I have two fields, timein &amp; timeout, both defined
as type "time".&nbsp; how can
<br>i get the difference between the two??&nbsp; 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!&nbsp; 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 &lt; 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>&nbsp;
<p>I use PostgreSQL v6.5.0 (09-04-1999) on Red&nbsp;Hat LINUX 5.2 with
2.2.5 kernel.
<br>--&nbsp;<br>
Best,<br>
&nbsp; George Moga,<br>
&nbsp; george(at)flex(dot)ro<br>
&nbsp; Braila,ROMANIA
<br>&nbsp;</html>

Attachment Content-Type Size
unknown_filename text/html 1.3 KB

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message José Soares 1999-04-30 12:45:51 Re: [SQL] time intervals
Previous Message Mark Jewiss 1999-04-30 08:10:00 Re: [SQL] time intervals