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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:27:56+00:00 2026-05-26T04:27:56+00:00

In the project there a functionality that lets you book the place during the

  • 0

In the project there a functionality that lets you book the place during the day, they have to enter the day, the start time and final time from 7:00 am to 12:00 AM (midnight) or 1:00 AM, for example if someone enter date=21/oct/2011 start time=8:00 pm and end time 12:00 am (he book the place from 8:00 pm until 12:00 am) the webform send to the store procedure 20:00 and 00:00 to check the table to see if is available, if someone already book in the same day until midnight it is store like this
startime=23:00 endtime=00:00

so when i check the new client it has to return that there a reservation already in the range of time,
my query is not efficient but it working from the 7:00 to 23:00 range, it fails when from the webfrom enters a endtime 12 am (00:00 on sql) because the starttime es greater than the end time

this is my query

select COUNT(*)
    from table1
    where id_place=@id_place
    and date=@date  
       and (
           (@start_time=res_start_time and @end_time=res_end_time)
        or (@start_time > res_start_time and @start_time < res_end_time)
        or (@end_time > res_start_time and res_end_time < res_end_time)
        or (res_start_time > @start_time and res_start_time < @end_time)
        or (res_end_time > @start_time and res_end_time < @end_time)
        or (res_start_time < @start_time and res_end_time >@end_time)
          )     


    -- @start_time  = start time of the reservations (from webform)
    -- @end_time    = end time of the reservations (from webform)

    -- res_start_time= represents the start time column
    -- res_ebd_time= represents the end time column

i need help on two things, how i solved the issue when i have to check times like 12:00 am or 1:00 am that are already in the table like the example at the begins of the question and to check my query because is think there has to be a better solution to implement this kind of functionality

  • 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-26T04:27:57+00:00Added an answer on May 26, 2026 at 4:27 am

    You obviously have a date somewhere in the table, as well, or you would not be able to book resources. This leads to a couple of possibilities.

    1. Query both time and date (can get complex, but you can make this a udf for reuse)
    2. Use DateTime instead of date and time columns
    3. if in SQL Server, consider creating a CLR function to handle this, as the CLR (.NET code) will more efficiently determine “is in time range”

    I am sure there are other possibilities. The key point here is it sounds like your algorithm is failing largely due to events that spill over to another day. If that is correct, bring the day into the equation is your best bet. This can end up as a rather complex SQL statement, a change of data types (datetime instead of date and time) or creating a .NET function (CLR) to help more efficiently determine “is in range”.

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

Sidebar

Related Questions

I have a project where there are multiple applications that have some common configuration
I have a library Eclipse project/workspace containing functionality that is occasionally delivered to a
I have a project which has shared functionality between three other projects and have
In my project there are situations where we have to send xml messages (as
In my project there are some 'Prototype' factories that create instances by cloning a
Is there a jQuery project out there, that create on of these Password-strength-meters right
I have a project where there are Windows, FreeBSD and Linux servers. I have
So I have a project where there is some automatic initialization going on through
I have upgraded my solution from VS2008. In our web project there are 2
Let's say you have a project that will involve two web applications (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.