多谢LucasLynn 版主的指点,问题已解决
下面是在ADP中写的存储过程,其中@firstDay为要查询月的第一天,@LastDay为要查询的最后一天
Alter Procedure "JiaTsM"
(@FirstDay datetime,@LastDay DateTime)
As
declare @Y int,@M int
set @Y=year(@FirstDay)
set @M=month(@FirstDay)
SELECT 员工,
Convert(int,Case When 终止日期>@LastDay Then @LastDay Else 终止日期
End-Case When 起始日期<@FirstDay Then @FirstDay Else 起始日期 End)
As 天数
From 请假表
WHERE
((year(起始日期)=@Y and month(起始日期)=@M) or
(year(终止日期)=@Y and month(终止日期)=@M) or
(起始日期<@FirstDay and 终止日期>@LastDay))
return
[此贴子已经被作者于2005-11-5 17:26:58编辑过]
|