How to find matching time intervals for more than 2 users

Viewed 772

Find best suitable time from given time interval of different users.

Rows: 5
fid  userid  FromDateTime           ToDateTime          flag
62   1   2012-07-18 01:48:20    2012-07-18 02:55:20     1
63   1   2012-07-18 10:30:46    2012-07-18 12:54:46     1
64   1   2012-07-18 18:50:24    2012-07-18 20:35:24     1
67   1   2012-07-18 15:03:36    2012-07-18 16:03:36     1
68   2   2012-07-18 21:10:47    2012-07-18 23:10:47     1

Above table show different free timesperiods available for different user, for examaple:

user1 is free in

2012-07-18 01:48:20   to   2012-07-18 02:55:20 , 
2012-07-18 10:30:46   to   2012-07-18 12:54:46 
......

user 2 is only free between this time period:

2012-07-18 21:10:47   to   2012-07-18 23:10:47 

Now I want to find out one best time interval in which both user can schedule their meeting.

5 Answers
Related