-4
create table timetable( work_date date, tech_id int,
    block_1_firsthalf_start_time datetime,  block_1_end_time datetime,
    block_2_secondhalf_start_time datetime, block_2_end_time datetime,
    block_3_over_time datetime, block_3_over_end_time datetime,
    block_4_first_break_start_time datetime,    block_4_first_break_end_time datetime,
    block_5_second_break_start_time datetime,   block_5_second_break_end_time datetime)

insert into timetable values(
'8/6/2013', 1,
    '8/6/13 6:00 AM',   '8/6/13 10:00 AM',
    '8/6/13 11:00 AM',  '8/6/13 6:00 PM',
    '8/6/13 6:30 PM',   '8/6/13 8:00 PM'
    '8/6/13 7:00 AM',   '8/6/13 8:00 AM',
    '8/6/13 5:00 PM',   '8/6/13 5:30 PM')

another table:

create table jobtable(tech_id   int,Job_starting_time datetime, Job_end_time datetime)

insert into jobtable values(1,  '8/6/13 7:00 AM','8/6/13 8:00 AM')

Now need to find free time in a day for the employee.pl share how can we make it.

4

1 回答 1

0

您的数据结构应规范化为块/作业列表

TechID   StartDateTime   EndDateTime
1        2013-6-8 06:00  2013-6-8 10:00
1        2013-6-8 11:00  2013-6-8 18:00
...

然后更容易找到不与现有数据相交的时间段,并且您不会将您的技术人员限制在每天有限数量的时间段内。

于 2013-09-03T12:06:14.323 回答