pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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 &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@flex.ro<br>
&nbsp; Braila,ROMANIA
<br>&nbsp;</html>




view thread (9+ messages)  latest in thread

Message-ID: <37297D89.1B186907@flex.ro>
Permalink:  ../37297D89.1B186907@flex.ro/
Also on:    postgresql.org/message-id/37297D89.1B186907@flex.ro

 · 

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: 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