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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:15:52+00:00 2026-05-30T17:15:52+00:00

I have a certain event in the calendar assigned to a storeID that has

  • 0

I have a certain event in the calendar assigned to a storeID that has a sdate (ShowDate) and an hdate (HideDate). Now for every new event with this storeID, I need to make sure that there’s no overlap with an existing date period. Does that make sense? How do I do that? I read about stuff but couldn’t figure out how to “insert only if not overlap”.

  • 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-05-30T17:15:54+00:00Added an answer on May 30, 2026 at 5:15 pm

    In general, if you have two ranges with S1..E1 and S2..E2 as the start and end values of the ranges, then you have an overlap if:

    • S1 < E2 and
    • S2 < E1

    This is symmetric, which is good (and reassuring). You will need to decide carefully whether those ‘less than’ operations should be ‘less than or equal’; both can make sense, depending on how you store your data (open vs closed vs half-open or open-closed and closed-open ranges, etc). You can see a diagram of the possibilities on the question ‘Determine whether two date ranges overlap’.

    In your context, the ‘ShowDate’ corresponds to the start date, and the ‘HideDate’ corresponds to the end date.

    It sounds rather as if you want to do a ‘conditional insert’, too. In this case, assuming that your StoreID is 1001, the ShowDate is 2012-03-21 and the HideDate is 2012-03-28, then you might write:

    INSERT INTO Calendar(StoreID, ShowDate, HideDate, ...)
       SELECT 1001, '2012-03-21', '2012-03-28', ...
         FROM Dual
        WHERE NOT EXISTS(SELECT * FROM Calendar C2
                          WHERE C2.StoreID   = 1001
                            AND C2.ShowDate  < '2012-03-28'
                            AND '2012-03-21' < C2.HideDate
                        );
    

    The values in the SELECT-list are those you want to add to the Calendar table. The sub-select means you get either 0 rows (because there is an overlap) or 1 row (because there is no overlap) with the data for your new value.

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

Sidebar

Related Questions

I have a program that is listening to a certain event file handle. Is
I have a socket.io server listening for certain events on sockets. Whenever an event
In my app I have certain events that trigger a lot of emails (~100).
I have a webpage that plays a 'chime' sound when certain events occur. Problem
I have certain PHP class methods that access external variables. These variables are not
I have certain panels on my page that are hidden under certain circumstances. For
I have certain critical bash scripts that are invoked by code I don't control,
I have certain initializing functions that I use to set up audit logging on
Can I have certain settings that are universal for all my users?
I have a function, singleFrameEventHandler, that I wish to be called when a certain

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.