CREATE PROCEDURE dbo.ABC
@Month as int
AS
BEGIN
Declare @Start as smalldatetime -- '10/01/2005'
Declare @End as smalldatetime -- '11/01/2005'
SET @Start = Cast((cast(@Month as char(2)) + '/01/' + year(getdate())) as smalldatetime)
SET @Start = Cast((cast((@Month+1) as char(2)) + '/01/' + year(getdate())) as smalldatetime)
SELECT 姓名 ,
DATEDIFF(day,
CASE 起始日期
when 起始日期>=@End then @End
when 起始日期<@Start then @Start
Else 起始日期
END
,
CASE 结束日期
when 结束日期>=@End then @End
when 结束日期<@Start then @Start
Else 结束日期
END
)
AS 请假日期
FROM 表名
END
-- 如果是五天工作制,还要考虑消除周末
原帖来自于网易社区:http://p5.club.163.com/viewArticleByWWW.m?boardId=database&articleId=database_1075e61c
抄回来得7444390 以上均为抄袭,呵呵
[此贴子已经被作者于2005-11-12 11:03:35编辑过]
|