From pvelasquez@its.co.cr Fri May 28 20:39:46 2004 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 67367D1E178 for ; Fri, 28 May 2004 17:39:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16497-01 for ; Fri, 28 May 2004 17:39:41 -0300 (ADT) Received: from antispam.its.co.cr (unknown [196.40.39.82]) by svr1.postgresql.org (Postfix) with ESMTP id 44678D1E001 for ; Fri, 28 May 2004 15:29:24 -0300 (ADT) Received: from localhost.localdomain (unknown [192.168.226.10]) by antispam.its.co.cr (Postfix) with ESMTP id 65EA32D61 for ; Fri, 28 May 2004 12:29:26 -0600 (CST) Received: from its.co.cr (hades.its.co.cr [196.40.31.147]) by localhost.localdomain (8.11.6/8.11.6) with ESMTP id i4SIX2s13283 for ; Fri, 28 May 2004 12:33:02 -0600 Message-ID: <40B784A9.70306@its.co.cr> Date: Fri, 28 May 2004 12:27:53 -0600 From: Pablo Velasquez Rivas User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: About intervals Content-Type: multipart/alternative; boundary="------------090101020403020301080207" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: * X-Archive-Number: 200405/219 X-Sequence-Number: 17933 This is a multi-part message in MIME format. --------------090101020403020301080207 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi all. I have a table with some timestamps fields. For example this table: * date1 | date2 -----------------------------+--------------------------- 2004-03-01 11:20:00 | 2004-03-01 11:55:00* If I do a query like this, I get: / SELECT date2 - date1 as diff FROM table/; * diff ------- 00:35 (1 row) * but if I do a query like this, I get: / SELECT date2 - date1 as diff FROM table WHERE date2 - date1 >= interval '15:00';/ * diff ------ (0 rows) * What can I do to do a query like the previous one , and get the right answer?? Thanks !! -- == == Pablo A. Velasquez Rivas Computer Science Engineer == == / All programmers are optimists / -- Frederick P. Brooks, Jr. --------------090101020403020301080207 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hi all.
I have a table with some timestamps fields. For example this table:

              date1        |         date2       
-----------------------------+---------------------------
 2004-03-01 11:20:00 | 2004-03-01 11:55:00


If I do a query like this, I get:

 SELECT date2 - date1 as diff FROM table;
 diff 
-------
 00:35
(1 row)


 but if I do a query like this, I get:
 SELECT date2 - date1 as diff FROM table WHERE date2 - date1 >= interval '15:00';
 diff
------
(0 rows)

What can I do to do a query like the previous one , and get the right answer??

Thanks !!
--
Firma ==                                 ==
   Pablo A. Velasquez Rivas
Computer Science Engineer
==                                 ==
All programmers are optimists -- Frederick P. Brooks, Jr.
--------------090101020403020301080207-- From bruno@wolff.to Fri May 28 21:18:30 2004 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 835C0D1B3CA for ; Fri, 28 May 2004 18:18:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 41236-06 for ; Fri, 28 May 2004 18:18:30 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 85144D1B34D for ; Fri, 28 May 2004 18:18:28 -0300 (ADT) Received: (qmail 1924 invoked by uid 500); 28 May 2004 21:23:54 -0000 Date: Fri, 28 May 2004 16:23:54 -0500 From: Bruno Wolff III To: Pablo Velasquez Rivas Cc: pgsql-sql@postgresql.org Subject: Re: About intervals Message-ID: <20040528212354.GB1689@wolff.to> Mail-Followup-To: Pablo Velasquez Rivas , pgsql-sql@postgresql.org References: <40B784A9.70306@its.co.cr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40B784A9.70306@its.co.cr> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/220 X-Sequence-Number: 17934 On Fri, May 28, 2004 at 12:27:53 -0600, Pablo Velasquez Rivas wrote: > > but if I do a query like this, I get: > / SELECT date2 - date1 as diff FROM table WHERE date2 - date1 >= > interval '15:00';/ > * diff > ------ > (0 rows) > * > What can I do to do a query like the previous one , and get the right > answer?? It looks like 15:00 is being taking to mean 15 hours 0 minutes. The more normal syntax for specifying 15 minutes is '15 minutes. So you probably want: SELECT date2 - date1 as diff FROM table WHERE date2 - date1 >= interval '15 minutes';