从这个表中2008-01-01 00:00:00.000
2008-01-05 00:00:00.000
2008-01-06 00:00:00.000
2008-01-12 00:00:00.000
2008-01-13 00:00:00.000
2008-01-19 00:00:00.000
2008-01-20 00:00:00.000...
查处报到日--完成日的日期
select * from 表 where 字段 between 报到日 and 完成日
2008-01-05 00:00:00.000
2008-01-06 00:00:00.000
2008-01-12 00:00:00.000
2008-01-13 00:00:00.000
2008-01-19 00:00:00.000
2008-01-20 00:00:00.000...
查处报到日--完成日的日期
select * from 表 where 字段 between 报到日 and 完成日
--> 测试数据: @s
declare @s table (报道日 datetime,完成日 datetime)
insert into @s
select '2008-01-01','2008-01-08' union all
select '2008-01-11','2008-04-19'--> 测试数据: @08年假日列表
declare @08年假日列表 table (data datetime)
insert into @08年假日列表
select '2008-01-01 00:00:00.000' union all
select '2008-01-05 00:00:00.000' union all
select '2008-01-06 00:00:00.000' union all
select '2008-01-12 00:00:00.000' union all
select '2008-01-13 00:00:00.000' union all
select '2008-01-19 00:00:00.000' union all
select '2008-01-20 00:00:00.000'
select *,节假日=(select count(1) from @08年假日列表 where data between a.报道日 and 完成日) from @s a
>= 4 THEN '準時' END AS DiffCreateDate,(select count(*) from asu_calendar as b where a.work_start_date < b.day and b.day <a.oa_finish_date and b.company_code = 'A001' and b.HOLIDAY_TYPE IS NOT NULL) as holiday
FROM dbo.HR_PRE_USER AS a
WHERE (OA_TYPE <> 0) AND (HIRE_STATUS = 1)以上,我表述的确实比较模糊了,不好意思。