Hello All,I'm looking for ideas on this one. I have two tables. One table stores a schedule that shows all time frames you are scheduled to work. The other stores the actual times worked.ExamplesCreate Table #TempScheduled( AgentName varchar(50), BeginDate datetime, BeginTime datetime, EndTime datetime)Insert Into #TempScheduledSelect 'Bob Smith','01/04/2012','01/04/2012 12:00','01/04/2012 15:00' union allSelect 'Bob Smith','01/04/2012','01/04/2012 15:15','01/04/2012 17:00' union allSelect 'Bob Smith','01/04/2012','01/04/2012 18:00','01/04/2012 19:30' Create Table #TempActual( AgentName varchar(50), BeginDate datetime, BeginTime datetime, EndTime datetime)Insert Into #TempActualSelect 'Bob Smith','01/04/2012','01/04/2012 12:01:35','01/04/2012 12:30:00' union allSelect 'Bob Smith','01/04/2012','01/04/2012 12:50:00','01/04/2012 15:01:47' union allSelect 'Bob Smith','01/04/2012','01/04/2012 15:17:00','01/04/2012 16:59:45' union allSelect 'Bob Smith','01/04/2012','01/04/2012 18:03:00','01/04/2012 19:27:16'
Let's say I want to compare Bob's actual worked time with his scheduled. I want to copy all times that he was not working when he should have been, such as the 1 minute and 35 seconds he was late logging in the first time and the 20 minutes he logged out for at 12:30-12:50 so I can get a total sum. I don't care if he worked when he was not supposed to, only if he didn't work when he was supposed to. Anyone have any ideas? Thanks!