>Dear Dragan,
>
>It was funny about 0.02... however, my appointment is developed "graphically", so couple of pixels is important.
>
>Actually, your approach can be done in grid format very quickly, which I'd already done. Forbidden double-booking is not possible, the doctors love to fill his/her appointment fully, even they went out everyday.
I didn't say we enforced all of these rules... just that rules existed :). We also had waiting lists - which would just tell the doctor how many people are (probably) outside, waiting - but we also allowed for the emergencies, like his wife's sister having a bent eyelash and being rushed in :).
>Also, in Multiple doctors situation, the clients may want to see who is available in particular time slots. Therefore, overlapping is inevitable in my case.
Ah - we had one cursor per doctor, i.e. as many schedules as we had doctors. They all went into the same table, of course.
>
>*** Checking whether double-booking
>t1 = appt.apptTime1
>t2 = appt.apptTime2
>SELECT distinct appt_id FROM appt WHERE <b>appttime1 <= t1</b> AND;
((t1 between appttime1 AND appttime2) OR;
(t2 between appttime1 AND appttime2)) ;
INTO CURSOR t4
>IF RECCOUNT('t4')>0
> GO BOTTOM in t4
> nLeft = nLeft+7*RECCOUNT('t4')
>ENDIF
>USE IN T4
>
The part I've bolded seems to be a leftover from a previous version... because you should get correct overlap detection without it as well. Also, I remember the minimal detection check was simpler than that... should be just
where t1<=apttime2 and t2>=apttime1
IOW, they overlap if first starts no later than the second ends, and first ends later than the second begins.
I remember spending an hour with a colleague over this (we drank nothing but coffee!) and this was the simplest and fastest overlap check. Though this wasn't about doctors, it was about golf... but overlap is overlap.