Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:12:15+00:00 2026-06-09T05:12:15+00:00

I am trying to figure out if any dates in a table for a

  • 0

I am trying to figure out if any dates in a table for a particular ID overlap. Here is an example of my table

ID   |  EffDate    | ExpDate
---------------------------------
1    |  2000-01-01 | 2010-12-31
2    |  2000-01-01 | 2050-12-31
1    |  2011-01-01 | 2011-12-31
1    |  2011-12-31 | 2050-12-31

In TableA I need to check to make sure that none of the ID’s intersect with “themselves” so none of the 1’s can intersect with any other one but doesn’t matter if the eff and exp dates intersect with ID 2.

Not looking for a complete answer just a starting point.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:12:16+00:00Added an answer on June 9, 2026 at 5:12 am

    This finds an overlap between two of your rows with ID equal to 1:

    declare @TabA table (ID int,EffDate datetime2,ExpDate datetime2)
    insert into @TabA(ID,EffDate,ExpDate) values
    (1,'20000101','20101231'),
    (2,'20000101','20501231'),
    (1,'20110101','20111231'),
    (1,'20111231','20501231')
    
    select
        * --TODO -Pick columns
    from
        @TabA t1
            inner join
        @TabA t2
            on
                t1.ID = t2.ID and
                t1.EffDate <= t2.ExpDate and --Play with these
                t1.ExpDate >= t2.EffDate and --For Inclusive/Exclusive
                t1.EffDate < t2.EffDate
    

    Result:

    ID          EffDate                ExpDate                ID          EffDate                ExpDate
    ----------- ---------------------- ---------------------- ----------- ---------------------- ----------------------
    1           2011-01-01 00:00:00.00 2011-12-31 00:00:00.00 1           2011-12-31 00:00:00.00 2050-12-31 00:00:00.00
    

    You can play with the comparison operators to make either or both of EffDate and ExpDate inclusive or exclusive boundary values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the inputs and the outputs of any SQL Server
I'm trying to figure out if there is a css property (or any other
I am trying to figure out how to declare my delegates without getting any
Any Access guru's out there that can help me out? Trying to figure out
I'm trying to figure out a SQLquery. I have a table of vote data
Trying to figure out how I can do this properly. The print_r looks like
trying to figure out why this is happening - I have an input text
Trying to figure out why my silverlight app suddenly just displays nothing (right click
Trying to figure out how to type (via events not set the value) on
Trying to figure out a regex for validating a network path ie: \\comp\xyz or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.