Compare time

1. Junior Member
Join Date
Dec 1969
Posts
3

## Compare time

i have to add movie schedules into database but i dont know how to compare the time to noe if it can be added. E.g if there is an existing movie schedule from 9:00a.m to 11:00a.m, it means i cannot add a schedule at 10:00a.m but how do i check so? Please help.

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Good question...

...so let&#039;s make you think about it.<BR><BR>Let&#039;s take your example.<BR><BR>There&#039;s already a movie scheduled from 09:00 to 11:00, right?<BR><BR>And now let&#039;s say you are asked to put in other movies with the following start and end times:<BR><BR>10:00 to 11:30<BR>08:30 to 12:00<BR>09:30 to 10:30<BR>11:00 to 12:30<BR>07:30 to 09:00<BR><BR>Which of those *can* be scheduled? <BR><BR>Just figure it out in your head.<BR><BR>************************************* *******************<BR>Don&#039;t peek at the answer!<BR>*************************************** *****************<BR><BR>If you said:<BR>NO - 10:00 to 11:30<BR>NO - 08:30 to 12:00<BR>NO - 09:30 to 10:30<BR>YES - 11:00 to 12:30<BR>YES - 07:30 to 09:00<BR>you are right. Now, *HOW* did you figure that out? <BR><BR>If you got it wrong, go back and look again. Try to see where you messed up.<BR><BR>When you have it right...<BR><BR>Try telling us, *in words*, what you did. Or, if it&#039;s easier for you, draw a diagram or timeline. <BR><BR>But figure out how you, *as a human*, would solve the problem. *THEN*, if you can&#039;t figure out how to translate your human language to computer language, we can help. But let&#039;s see if you can start with the human language, first, okay?<BR><BR><BR>

3. Junior Member
Join Date
Dec 1969
Posts
3

## RE: Good question...

sorry to have cross-posted....i guess im too anxious coz my project deadline is nearing... thanx for replying =)

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## So you figured it out?

???<BR><BR>You *accept* new movies if they start on or after the ending time of the existing one *OR* if they end on or before the beginning of the existing one.<BR><BR>Right?<BR><BR>If newStartTime &#062;= existingEndTime OR newEndTime &#060;= existingStartTime Then<BR>&nbsp; &nbsp; &#039; okay<BR>Else<BR>&nbsp; &nbsp; &#039; overlap...reject<BR>End If<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•