PDA

View Full Version : seeing if a date-time overlaps another time


arianhojat
08-18-2005, 10:02 PM
hello all,
had a time question in mysql...
i have a start and end time for a meeting table and i am comparing whether a new meeting conflicts with another meeting in same room on the same date.

i was wondering if i could check whether the 'date-time duration' in anyway overlaps another meetings date-time duration. visualized below...
............|____compareToThisMeeting__|
.....|_________meetingNewOverlaps__________|

i was doing something dumb before i realized i needed soemthing more complex (checking whether the start time of new meeting was 'BETWEEN' the start and end times of a meeting and whether the end time time is as well but i forgot the duration/middle value hehe).

(using asp)
and just returning booleans with a mySQL SELECT statement is what i am looking for like...

//within a loop in asp for meetings on same date/room
"SELECT '"+ year+"-"+month +"-"+day +" " + startHourString +":" + startMinuteString +":00''"+ " BETWEEN '"+ thisMeetingStart +"' AND '"+ thisMeetingEnd +"'"; (this doesnt cover the 'middle' overlap areas though)

Thanx if anyone can help.
Arian

arianhojat
08-18-2005, 10:12 PM
i guess i could check if the start time of the new meeting is < the start time of the meeting its being compared to AND the end time of the new meeting > the the end time of that meeting. but then i also check if its in between. i was hoping some fantastic date-time-duration-overlap(datetime1Start, datetime1End, datetime2Start, datetime2End) existed hehe. looking forward for suggestions

raf
08-19-2005, 04:13 PM
welcome here!

i don't realy understand your problem.
why can't you just check that
((the start time of the new meeting is >= the enddtime of the existing meeting) or (that the endtime of your new meeting is <= the starttime of the existing meeting))