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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:33:44+00:00 2026-06-12T13:33:44+00:00

Scenario UDPATE Please ignore the commented section. After thinking for an alternative, I came

  • 0

Scenario

UDPATE

Please ignore the commented section. After thinking for an alternative, I came up with this:

Let’s say I have

$date = '2012-10-03 13:00:00'

The time interval range is

2012-10-03 12:00:00 to 2012-10-03 14:00:00

Now $date falls between the time range mentioned above. Any ideas on how to compare a date time with a range of date time? I’ve come across functions which compare either just date or just time but not both at the same time. Any help much appreciated.

/*I'm building a school timetable and want to make sure that a room cannot be assigned to two different periods if it is already occupied. I have datetime values of **`2012-10-03 13:00:00`** (the start time of a period. Let's call it **abc** for reference) and **`2012-10-03 13:30:00`** (the end time of a period. Let's call it **xyz** for reference). 

My database table contains columns for room number assigned for a period and the start and end time of that period. Something like this:

    room_no | start_time          | end_time
       5      2012-10-03 13:00:00   2012-10-03 14:30:00

This means for October 3, 2012 room 5 is occupied between 1pm and 2:30pm. So the datetime values that I have (abc & xyz) will have to be assigned to a room other than 5.

I'm at a loss of ideas on how to go about validating this scenario, i.e. make sure that the period with time interval between abc & xyz cannot be assigned room number 5.

Any help would be appreciated. Thanks in advance

PS : I'm not asking for code. I'm looking for ideas on how to proceed with the issue at hand. Also, is there a way a query can be build to return a row if `abc` or `xyz` lie between `start_time` and `end_time` as that would be great and reduce a lot of workload. I could simply use the number of rows returned to validate (if greater than 0, then get the room number and exclude it from the result)*/
  • 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-12T13:33:45+00:00Added an answer on June 12, 2026 at 1:33 pm
    if(StartTime - BookingTime < 0 && BookingTime - EndTime < 0)
    {
      // Booking time is already taken
    }
    

    You can do this in SQL with TIMEDIFF().

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

Sidebar

Related Questions

Please cosider this scenario: I have a form with 3 drop down list.I place
Can someone please help? Here is my jQuery. The scenario is this, I have
Scenario 1 (That Works) This is a POC i created. I have a script
So imagine this scenario, I have a list and it has a bit of
Let's say you have a Classroom entity with an collection of Student entities. What
please help me with this : The scenario: building a system (Backend :Mysql ,
I have tried to implement this scenario . I have created Code First model,
In my android app I have this scenario - I have a Gallery where
Could somebody please give their input into the following scenario: I have an Administrator
In my android application the scenario is this - I have several images stored

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.