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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:42:27+00:00 2026-05-23T15:42:27+00:00

I am currently developing an event management system where the database stores time slots

  • 0

I am currently developing an event management system where the database stores time slots as such:

SlotId | DateTime            | Duration  
-------+---------------------+---------------
 1     | 2011-06-06 15:00:00 | 5.0
 2     | 2011-06-06 14:00:00 | 3.0
 3     | 2011-06-07 11:00:00 | 8.0

Note that Duration is a DOUBLE in hours and DateTime is a TIMESTAMP.

In the table, we can clearly see that time slots 1 and 2 clashes, whereas time slots 2 & 3 and time slots 1 & 3 doesn’t clash. How can we write the SQL statement to detect clashes between the two time slots?

  • 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-23T15:42:28+00:00Added an answer on May 23, 2026 at 3:42 pm

    Maybe I’m confused, but it looks like all three of those time slots overlap. Since they go From 11:00 – 19:00, 14:00 – 17:00, and 15:00 – 20:00 respectively (in reverse of your order, chronologically by start time). But if I understand your table correctly here is the code to find the overlaps

    SELECT CONCAT(T1.SlotId,  ' Overlaps ', T2.SlotId)
    FROM YourTable AS T1 JOIN YourTable AS T2 
    WHERE T1.SlotId <> T2.SlotId AND 
        T1.DateTime <= T2.DateTime AND 
        DATE_ADD(T1.DateTime,INTERVAL SEC_TO_TIME(T1.Duration * 3600) HOUR_SECOND) > T2.DateTime
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a system that has need for a session time out
I am currently developing a Rails application using a database that was designed before
I'm currently developing a PHP application that's using an Access database as a backend.
I'm currently developing a program in Java where a certain event must be triggered
I'm currently developing a new web application. This is the first time I'm using
I'm currently developing an app for selling tickets to an event. I'm in need
I am currently developing a wpf c# application. I have added to event triggers
first time poster here! I'm a Senior Computer Science Student and I'm currently developing
Currently developing an application using the newest version of symfony, obtained through PEAR. This
Currently developing a PHP framework and have ran into my first problem. I need

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.