473,385 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Scheduling application - logic problem

Hi, I originally posted in the db group but thought this might be more
appropriate here.

I have a scheduling application which allows the user to reserve timeslots
for various things but I'm having trouble figuring out how to detect if a
reservation being added is conflicting with an existing reservation.
Basically its a logic problem.

I am currently able to detect timeslots that overlap start and/or end times
but cant figure out how to detect other conflicts.

For example, here's my check routine:
schedcheck = "Select * FROM Schedule WHERE ItemIndex = "&strItemIndex&" AND
Sched_Date = #"& strSched_Date &"# AND (Sched_Start BETWEEN # "&
strSched_Start &" # AND # "& dateAdd("n",-1,strSched_End) &" # OR Sched_End
BETWEEN # "& dateAdd("n",1,strSched_Start) &"# AND # "& strSched_End &"#) "

This detects conflicts such as a new reservation being scheduled from 1:00
pm to 4:00 pm and there's already an existing reservation from 2:00 pm to
5:00 pm. Since there is an overlap of times, it catches it, but what I'm
missing is if I have, say an existing reservation from 1:00 pm to 5:00 pm
and someone tries to schedule one from 2:00 pm to 4:00 pm. Since the new
reservation times don't overlap the existing start or end times, and are
actually in between the existing start and end times, it doesn't get caught.

How can I adjust or re-do my statement to catch every possible conflict?

Any help or suggestion greatly appreciated!
Aug 15 '05 #1
2 1450
Forgive me if I'm wrong/misunderstanding...but wouldn't you just have to
evaluate whether the start or end is between the start and end of the
already scheduled event?

Assume A & B = Start/End for new item
Assume C & D = Start/End for old item

Problems:
A < C & B Between C & D
A Between C & D and B between C & D
A Between C & D and B > D

So couldn't you just say If A Between C & D OR B Between C & D then you have
a conflict?

"Jake" <sp******@alltel.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi, I originally posted in the db group but thought this might be more
appropriate here.

I have a scheduling application which allows the user to reserve timeslots
for various things but I'm having trouble figuring out how to detect if a
reservation being added is conflicting with an existing reservation.
Basically its a logic problem.

I am currently able to detect timeslots that overlap start and/or end times but cant figure out how to detect other conflicts.

For example, here's my check routine:
schedcheck = "Select * FROM Schedule WHERE ItemIndex = "&strItemIndex&" AND Sched_Date = #"& strSched_Date &"# AND (Sched_Start BETWEEN # "&
strSched_Start &" # AND # "& dateAdd("n",-1,strSched_End) &" # OR Sched_End BETWEEN # "& dateAdd("n",1,strSched_Start) &"# AND # "& strSched_End &"#) "
This detects conflicts such as a new reservation being scheduled from 1:00
pm to 4:00 pm and there's already an existing reservation from 2:00 pm to
5:00 pm. Since there is an overlap of times, it catches it, but what I'm
missing is if I have, say an existing reservation from 1:00 pm to 5:00 pm
and someone tries to schedule one from 2:00 pm to 4:00 pm. Since the new
reservation times don't overlap the existing start or end times, and are
actually in between the existing start and end times, it doesn't get caught.
How can I adjust or re-do my statement to catch every possible conflict?

Any help or suggestion greatly appreciated!

Aug 15 '05 #2
"Jake" <sp******@alltel.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi, I originally posted in the db group but thought this might be more
appropriate here.

I have a scheduling application which allows the user to reserve timeslots
for various things but I'm having trouble figuring out how to detect if a
reservation being added is conflicting with an existing reservation.
Basically its a logic problem.

I am currently able to detect timeslots that overlap start and/or end
times
but cant figure out how to detect other conflicts.

For example, here's my check routine:
schedcheck = "Select * FROM Schedule WHERE ItemIndex = "&strItemIndex&"
AND
Sched_Date = #"& strSched_Date &"# AND (Sched_Start BETWEEN # "&
strSched_Start &" # AND # "& dateAdd("n",-1,strSched_End) &" # OR
Sched_End
BETWEEN # "& dateAdd("n",1,strSched_Start) &"# AND # "& strSched_End &"#)
"

This detects conflicts such as a new reservation being scheduled from 1:00
pm to 4:00 pm and there's already an existing reservation from 2:00 pm to
5:00 pm. Since there is an overlap of times, it catches it, but what I'm
missing is if I have, say an existing reservation from 1:00 pm to 5:00 pm
and someone tries to schedule one from 2:00 pm to 4:00 pm. Since the new
reservation times don't overlap the existing start or end times, and are
actually in between the existing start and end times, it doesn't get
caught.

How can I adjust or re-do my statement to catch every possible conflict?

Any help or suggestion greatly appreciated!


m.p.i.asp.db was the right group and Mark Schupp's solution was the correct
one. In the future, please indicate which database and version you are using
as well as DDL for the tables involved. Also, please consider using a
parameterized query in lieu of dynamic sql for improved performance and to
avoid sql injection. Finally, please consider explicitly declaring the
columns you would like to retrieve instead of using "SELECT *". Here's a
parameterized query to retrieve a list of conflicting reservations:
[BEGIN Select_Conflicting_Reservations]
PARAMETERS prm_item_index INTEGER, prm_sched_start DATETIME, prm_sched_end
DATETIME;
SELECT <<Explicit Column List>>
FROM Schedule
WHERE ItemIndex = prm_item_index
AND Sched_Start <= prm_sched_end
AND Sched_End >= prm_sched_start
[END Select_Conflicting_Reservations]

Here are some related articles:
http://aspfaq.com/etiquette.asp?id=5003
http://aspfaq.com/etiquette.asp?id=5006
http://aspfaq.com/etiquette.asp?id=5009
http://aspfaq.com/show.asp?id=2096

Aug 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tony Proctor | last post by:
Hi everyone We're experiencing some serious anomalies with the scheduling of ASP threads. I'd be interested to hear if anyone knows what algorithm is used (e.g. simple round-robin, or something...
3
by: Muscha | last post by:
Hi, In our application we need to have a high performance scheduling framework. We want to be able to say for item 21 do an update on such and such time. We will have around 1 million items of...
3
by: mirek | last post by:
Hello, My ASP.NET application must have additional functionality which isn't typical for ordinary web use. It is: - connecting to the other server using specified protocol (an option to...
3
by: Alphonse Giambrone | last post by:
Can anyone point me toward a good example of an asp.net scheduling app? Preferrably in vb.net. TIA -- Alphonse Giambrone Email: a-giam at customdatasolutions dot us
1
by: Majed | last post by:
hi I'm planing to make scheduling app and need your advice on the best way to do that,and how to save the tasks to be executed and retrive their data at the right time. your input will be highly...
0
by: Lemune | last post by:
Hello. I need some help on building my sms services application (using modem). My application is to do some scheduling task based on daily, weekly and monthly. On the daily the choice are everyday,...
4
by: Dinsdale | last post by:
I'm looking at adding scheduling features to an application and I wanted to ask the community about any experience with scheduling components, either open source like from code project or from a...
4
by: Rahul | last post by:
Hello All, I have come accross a very interesting as well as a very complex scenario with my current project. My worry is the scheduling of email messages and execution of that based on the cron...
4
by: IanWright | last post by:
I'm just wondering if anyone could give me any starters here.... I have a need to create a simple scheduling application, that will choose from a pool of avaliable people and assign them to a...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.