Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 5D523B5DC02 for ; Wed, 20 Jul 2011 08:43:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 13893-01 for ; Wed, 20 Jul 2011 11:43:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from depesz.com (andy.depesz.com [88.198.47.100]) by mail.postgresql.org (Postfix) with ESMTP id BC049B5DC01 for ; Wed, 20 Jul 2011 08:43:16 -0300 (ADT) Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by depesz.com with esmtpa (Exim 4.76) (envelope-from ) id 1QjVBJ-0001Nr-EG; Wed, 20 Jul 2011 13:43:13 +0200 Date: Wed, 20 Jul 2011 13:43:12 +0200 From: hubert depesz lubaczewski To: Ludek Bouska Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6124: overlaps Message-ID: <20110720114312.GA27337@depesz.com> Reply-To: depesz@depesz.com References: <201107200609.p6K69mNj055558@wwwmaster.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201107200609.p6K69mNj055558@wwwmaster.postgresql.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.093 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.193 X-Spam-Level: X-Archive-Number: 201107/145 X-Sequence-Number: 30757 On Wed, Jul 20, 2011 at 06:09:48AM +0000, Ludek Bouska wrote: > > The following bug has been logged online: > > Bug reference: 6124 > Logged by: Ludek Bouska > Email address: ludek@bouska.info > PostgreSQL version: 8.3.7 > Operating system: FreeBSD 7.2-RELEASE-p3 > Description: overlaps > Details: > > script > select ('20110720'::date,'20110721'::date) overlaps > ('20110721'::date,'20110721'::date) > gives false. > > It is necessary to make it as > select ('20110720'::date,'20110721'::date+'1 day'::Interval) overlaps > ('20110721'::date,'20110721'::date) > for the 20110721 be realy overlapped. docs clearly state the reason: http://www.postgresql.org/docs/current/interactive/functions-datetime.html This expression yields true when two time periods (defined by their endpoints) overlap, false when they do not overlap. The endpoints can be specified as pairs of dates, times, or time stamps; or as a date, time, or time stamp followed by an interval. When a pair of values is provided, either the start or the end can be written first; OVERLAPS automatically takes the earlier value of the pair as the start. Each time period is considered to represent the half-open interval start <= time < end, unless start and end are equal in which case it represents that single time instant. This means for instance that two time periods with only an endpoint in common do not overlap. depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/