Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006

    Red face Unanswered: Can see it, can't put it to sql,...

    I have an odd thing to do in sql, it's got to count how many times it finds a gap between dates in the database, this is a 2003 one, not the shiny cool 2005 one
    Imagine a table with two fields, FromDate ToDate with in that order these values:
    01/01/01 - 02/01/01
    02/15/01 - 03/01/01
    02/20/01 - 04/01/01

    What I would like to do is see whether there are no overlaps in a give date range. So say I would want to see whether there are gaps between 01/01/01 and 06/01/01 it would return a count of two because between 02/01/01 and 02/15/01 there's a 2 week gap and there's a 2 months gap between 04/01/01 and 06/01/01.

    So I can see it but have no clue how to do it in plain sql,... can someone help? Also,.. without doing it in code, do you think it's possible to return the start and endate of the gaps instead?


  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    why did you post this in both the oracle and sql server forums? the solutions will be completely different | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2006
    well, it has to run on both.
    Why did you ask me the same question on both forums, the answer is the same.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts