pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Suha Onay <suhaonay@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Intersection of two date interval
Date: Fri, 26 Jan 2007 11:39:03 +0200
Message-ID: <49a67b230701260139n1153ee82x8ae91875118f3cd2@mail.gmail.com> (raw)

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

view thread (4+ messages)  latest in thread

Message-ID: <49a67b230701260139n1153ee82x8ae91875118f3cd2@mail.gmail.com>
Permalink:  ../49a67b230701260139n1153ee82x8ae91875118f3cd2@mail.gmail.com/
Also on:    postgresql.org/message-id/49a67b230701260139n1153ee82x8ae91875118f3cd2@mail.gmail.com

 · 

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: suhaonay@gmail.com
  Subject: Re: Intersection of two date interval
  In-Reply-To: <49a67b230701260139n1153ee82x8ae91875118f3cd2@mail.gmail.com>

* 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