Time values Comparition


I need to compare times with existing records. I am not getting logic.

My requirement is.

In a form UserInput is like this:

From Time: 9:30 Am To Time : 10: 30 am

but In a Table record are like this:

Rec1 From time: 09:00 Am ToTime: 10:00 am

Rec2 From time: 10:00 Am ToTime: 11:00 am

Rec3 From time: 7:00 Am ToTime: 08:00 am

Rec4 From time: 11:00 Am ToTime: 11:30 am

I need to compare, user FromTIme and ToTime between Timing should not exist in those records I need to get.

In this scenario I will get last 2 record.

Thanks in advance.

Hi sunil

You may apply the logic as below.

(User from time<=Table from time && Table from time <= User to time) || (User from time<=Table to time && Table to time <= User to time). if this conditon return false means you got desird result.