--判断 加班 时间段 是否重叠
--工号0100993 加班 加班日期 2016-01-09 起始时间08:30 结束时间17:30
select count(*) tcount from (
select case when (
('08:30'<tstarttime and '17:30'<=tstarttime and '17:30'>'08:30') --在原有时间段之前
or ('08:30'>=tendtime and '17:30'>'08:30')) --在原有时间段之后
then 1 else 0 end trs from ijb_sq --0为有重叠记录,0个0 无重叠时间段,n个0 n条重叠的记录。
where tcode='0103993' and tdate='2016-01-09' )t where trs=0
--对比数据库 若无重叠时间段 tcount =0 若有重叠时间段 tcount =N ( N 不等于0) N 条重叠的时间段
----判断 请假 时间段 是否重叠
--工号0100993 请假起始时间'2016-02-08 08:30' 请假结束时间2016-02-12 12:00'>
select count(*) tcount from (select case when ( --连接日期和时间 +
('2016-02-08 08:30'<tstart+' '+tstarttime and '2016-02-10 12:00'<=tstart+' '+tstarttime --在原有时间段之前
and '2016-02-10 12:00'>'2016-02-08 08:30') or
('2016-02-08 08:30'>=tend+' '+tendtime and '2016-02-10 12:00'>'2016-02-08 08:30')) --在原有时间段之后
then 1 else 0 end trs
from iqj_sq where tcode='0100893')t where trs=0
--0为有重叠记录,0个0 无重叠时间段,n个0 n条重叠的记录。