Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B72A49FA459 for ; Fri, 26 Jan 2007 05:39:08 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 05604-04 for ; Fri, 26 Jan 2007 05:39:05 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.190]) by postgresql.org (Postfix) with ESMTP id 7F6B79FA372 for ; Fri, 26 Jan 2007 05:39:05 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id x4so1138561nfb for ; Fri, 26 Jan 2007 01:39:04 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=IlSUlGZG15+5xBcv9OJvKOwGLzLAVA+Nz0iq+0D3XwxLCjPPSK5yiHBhQJGbgmE8qTL61sHl3z5G+KYSSB7W6Y9AUWFyVaao1Ub7g75hJaDyeDZdjn+nXPoWoQ+2CXEMiKl2NcIpaddf9bRxP1kGI2tEsxChX9fC9/Sr3d54oOA= Received: by 10.49.13.14 with SMTP id q14mr5348907nfi.1169804343673; Fri, 26 Jan 2007 01:39:03 -0800 (PST) Received: by 10.48.241.20 with HTTP; Fri, 26 Jan 2007 01:39:03 -0800 (PST) Message-ID: <49a67b230701260139n1153ee82x8ae91875118f3cd2@mail.gmail.com> Date: Fri, 26 Jan 2007 11:39:03 +0200 From: "Suha Onay" To: pgsql-sql@postgresql.org Subject: Intersection of two date interval MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_166764_24340933.1169804343635" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.611 tagged_above=0 required=5 tests=BAYES_20, HTML_10_20, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200701/130 X-Sequence-Number: 27282 ------=_Part_166764_24340933.1169804343635 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, How can i find the number of days in the intersection of 2 date interval? For example: 1st interval: (10.01.2007, 20.01.2007) 2nd interval: (13.01.2007, 21.01.2007) The intersection dates are: 13,14,15,16,17,18,19, 20 The result is: 8 How can i find the result, 8 in an sql query without using CASE statements? Table columns are id PK, date1 date, date2 date. Thanks for all your help. Suha ------=_Part_166764_24340933.1169804343635 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi,

How can i find the number of days in the intersection of 2 date interval?
For example:
1st  interval: (10.01.2007, 20.01.2007)
2nd interval: (13.01.2007, 21.01.2007)
The intersection dates are: 13,14,15,16,17,18,19, 20
The result is: 8

How can i find the result, 8 in an sql query without using CASE statements?

Table columns are id PK, date1 date, date2 date.

Thanks for all your help.


Suha


------=_Part_166764_24340933.1169804343635--