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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:01:06+00:00 2026-05-30T02:01:06+00:00

I am making a booking system where users can make appointments with each other.

  • 0

I am making a booking system where users can make appointments with each other.
What I need to do is make sure that the meetings do not clash time wise.

For example:
Meeting 1 is from 13:00 to 14:00.
Meeting 2 is from 13:30 to 14:30.

These meetings clash and therefore the booking should not be made.

Now when I try to do this I am not getting the desired result, sometimes it thinks the booking should not be made when it really should, and vice versa.

Here is my code:

if (OldBookingDate.Equals(NewBookingDate))
                {
                    // Check if (OldBookingTime -> OldEndTime) clashes with (NewBookingTime -> NewEndTime)
                    //  For Example (10:00 -> 12:00), (09:00 -> 11:00)
                    //  So this Clashes!
                    DateTime OldBookingTime_End = OldBookingTime_Start.AddHours(OldDurationInt);
                    DateTime NewBookingTime_End = NewBookingTime_Start.AddHours(NewDurationInt);

                    int Clash1 = OldBookingTime_Start.CompareTo(NewBookingTime_Start);
                    int Clash2 = OldBookingTime_End.CompareTo(NewBookingTime_End);
                    if ((Clash1 < 0) || (Clash2 > 0))
                    {
                        // If Clash1 -> Finishes before Meeting
                        // If Clash2 -> Finishes after Meeting
                        Available = true;
                    }
                    if ((Clash1 == 0) || (Clash2 == 0))
                    {
                        // Start and end is the same
                        Available = false;
                    }
                    if ((Clash1 > 0) || (Clash2 < 0))
                    {
                        // Intersects/Clashes with already booked meeting
                        Available = false;
                    }
                }

The main problem seems to be with the ((Clash1 > 0) || (Clash2 < 0)) if statement as when a booking should be made the first if statement sets available to true (as it should) but then this if statement then sets it to false.

How may I perform these checks properly to make sure the times do not clash?

  • 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-30T02:01:07+00:00Added an answer on May 30, 2026 at 2:01 am

    Try this:

    bool clashing = (OldBookingTime_Start <= NewBookingTime_End)
                 && (NewBookingTime_Start >= OldBookTime_End);
    
    Available = !clashing;
    

    See also:

    Determine Whether Two Date Ranges Overlap

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

Sidebar

Related Questions

I'm looking at making a booking system and I need to display all the
Making a flash page that can cycle through these three images on mouseclick. For
making an Access database (2003) that is mainly used by other programmers and tech
An email confirmation gets sent when my website users making a booking. I have
I am making a booking app now and have a problem. I need a
I am new with python and I am making a system that deals with
I am making a form that submits some values to a site for booking
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
I am making a doctor appointment slot booking mechanism,where in doctor appointment slots 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.