Programming/maths puzzler
Discussion
Ok - another one for the PH programming brainiacs...
I'm trying to write a bit of code that checks whether two events overlap in any way and seeing as I've not done any more maths than adding up my shopping list since leaving school *mumble* years ago I'm a bit stuck.
Let's say we have the following variables:
x = Event 1 start time
y = Event 1 length in hours
a = Event 2 start time
b = Event 2 length in hours
Basically I need a true/false response to determine whether there's a clash and therefore allow the event to be booked or not.
All I need is a formula, but if anyone knows how to do this in ASP/VBScript that would be nice
I'm trying to write a bit of code that checks whether two events overlap in any way and seeing as I've not done any more maths than adding up my shopping list since leaving school *mumble* years ago I'm a bit stuck.
Let's say we have the following variables:
x = Event 1 start time
y = Event 1 length in hours
a = Event 2 start time
b = Event 2 length in hours
Basically I need a true/false response to determine whether there's a clash and therefore allow the event to be booked or not.
All I need is a formula, but if anyone knows how to do this in ASP/VBScript that would be nice

That formula doesn't allow for event 2 to start before event 1...
This page is all about date time functions in visual basic and comparisons of them...
www.officecomputertraining.com/vbtutorial/tutpages/page32.asp
This page is all about date time functions in visual basic and comparisons of them...
www.officecomputertraining.com/vbtutorial/tutpages/page32.asp
greenv8s said:
This is a familiar graphics problem. Call the four times a1 a2 and b1 b2.
If you work out all the different combinations you will find there are six cases, four where the two intervals overlap and two where they don't. The ones where there is no overlap are (b2 < a1) and (b1 > a2).
Brilliant! Just the solution I needed. Many thanks to all everyone

Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


