Comparing times

T

The Iconoclast

Greetings to all!
I am trying to find out an efficient way of determining whether two or
more time scheds are in conflict.
Example:
Subj A - 9:00 am to 10:30 am - Mondays
Subj B - 9:30 am to 11:00 am - Mondays
Subj C - 10:30 am to 12:00 pm - Mondays
Subj D - 9:00 am to 10:30 am - Tuesdays
etc.

When comparing all subjects, (A and B) and (C and B) are in conflict
while (A and D) and (A and C) are not.

Are there any efficent routines that can do this?

Any help would be much appreaciated. Thank you in advance.

-MEM
 
A

Alex Dybenko

Hi,
for such things i am using following function:

Public Function IsOverlapping(ByVal Per1Beg As Date, _
ByVal Per1End As Date, _
ByVal Per2Beg As Date, _
ByVal Per2End As Date) As Boolean

If Per1Beg <= Per2Beg And Per1End <= Per2Beg Then Exit Function
If Per1Beg >= Per2End Then Exit Function

IsOverlapping = True
End Function

if Per1 and Per2 overlapping - it returns true
HTH
 
Top