sql-server-2008 R2-split-time-intervals-given-by-starttime-endtime-at-selected-point -
i have table has following data
create table #tempstudentschedulingrecord( seq_id int identity(1,1), student_id int , periodnumber int , cpstarttime datetime , cpendtime datetime , dateitem datetime , firstsegmentendtime datetime, secondsegmentendtime datetime )
now
insert #tempstudentschedulingrecord values(2730,1,'1900-01-01 07:25:00.000','1900-01-01 08:20:00.000','2010-10-05 00:00:00.000','2015-05-27 09:45:00.000','2015-05-27 16:00:00.000') insert #tempstudentschedulingrecord values(2730,1,'1900-01-01 08:25:00.000','1900-01-01 10:00:00.000','2010-10-05 00:00:00.000','2015-05-27 09:45:00.000','2015-05-27 16:00:00.000') insert #tempstudentschedulingrecord values(2730,1,'1900-01-01 10:05:00.000','1900-01-01 11:35:00.000','2010-10-05 00:00:00.000','2015-05-27 09:45:00.000','2015-05-27 16:00:00.000')
now here firstsegmenttime same in rows. want find total minutes scheduled before first segment end , classes included in first segment. find the total minutes scheduled between first segment end time , second segment end time , classes included in first segment.
here period 2 resides both segments.. how can calculate total minutes scheduled before first segment , second segment.
desired output is
student period cpstarttime cpendtime dateitem fset sset 2730 1 01/01/00 08:25 01/01/00 10:00 10/05/10 12:00 05/27/15 09:45 05/27/15 04:00 pm 2730 2 01/01/00 08:25 05/27/15 09:45 10/05/10 12:00 05/27/15 09:45 05/27/15 04:00 pm 2730 2 05/27/15 09:45 01/01/00 10:00 10/05/10 12:00 05/27/15 09:45 05/27/15 04:00 pm 2730 3 01/01/00 10:05 01/01/00 11:35 10/05/10 12:00 05/27/15 09:45 05/27/15 04:00 pm
Comments
Post a Comment