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 8661381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:29:03+00:00 2026-06-12T16:29:03+00:00

I am trying to find out if there is a way in sql (t-sql

  • 0

I am trying to find out if there is a way in sql (t-sql preferred) to identify if a date range falls between another date range.

for purposes of my example:
daterange1 = i have a defined date range, dates are 1/1/2012 – 1/5/2012
daterange2 = i have two other dates to work with, lets say 1/3/2012 and 1/4/2012

i am trying to have this to use in a CASE statement for something like this

CASE 
    WHEN daterange1 = 0 then result1
    WHEN daterange2 falls within daterange1 then result2 
    END as datestuff 

is this possible in SQL? I’m really stumped on this one, i know how to figure out if a single date falls between a range, but how can it be done with a date range? the answer doesnt necessarily need to be in a CASE statement but it is preferred.

  • 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-12T16:29:04+00:00Added an answer on June 12, 2026 at 4:29 pm

    How can you get daterange1 = 0, since it’s a range, i.e. 2 values?

    The proper test for overlapping dates is

    CASE WHEN @range1start <= @range2end
          and @range2start <= @range1end THEN 1 ELSE 0 END
    

    If you mean that daterange2 must fall ENTIRELY within daterange1, then

    CASE WHEN @range1start <= @range2start
          and @range2end <= @range1end THEN 1 ELSE 0 END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm trying to find out if there is a way to set the
I am trying to find out if there is a more optimal way for
been trying to find out if there is a way to pre-write the tag
I'm trying to find out if there's a way to know how much time
I am trying to find out if there is any API in C for
I'm trying to find out if there are any methods in Java which would
I'm trying to find out if there's a Wikipedia API (I think it is
I am trying to find out if there are any relevant measurements that LoadRunner
What I'm trying to find out is whether there is some sort of equivalence
I am trying to find out how to write an SQL statement that will

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.