0
使用DATEDIFF函数下面是我用来计算天的第二日排除周五和周六,而在SSRS
SELECT count(*) as NoofCalls, outside.ReferenceNo, outside.WorkflowType, outside.Department, inside.CompletedDate, outside.CommentResponse, outside.CommentText, outside.CommentUserDisplayName, outside.StepName, outside.Originator, outside.Subject, outside.StartTime, CAST(DATEDIFF(hh, outside.StartTime, inside.CompletedDate)/24.0 AS decimal(10,5)) AS CompDays
FROM
(
SELECT ReferenceNo, MAX(CommentDate) as CompletedDate
FROM FNCUSTOM.dbo.WorkflowHistory
WHERE WorkflowType IN (@WorkflowType) AND Department IN (@Department) AND Originator IN (@Originator) AND ReferenceNo IN (@Reference_No)
AND (StartTime between @StartDate AND @EndDate)
GROUP BY ReferenceNo
) inside
INNER JOIN FNCUSTOM.dbo.WorkflowHistory outside ON outside.ReferenceNo = inside.ReferenceNo AND outside.CommentDate=inside.CompletedDAte
GROUP BY outside.ReferenceNo, outside.WorkflowType, outside.Department, inside.CompletedDate, outside.CommentResponse, outside.CommentText, outside.CommentUserDisplayName, outside.StepName, outside.Originator, outside.Subject, outside.StartTime
我需要对排除之间FRIDAY &周六同时calulating CompDaysSQL
查询。
非常感谢您的帮助。
使用SSRS 2005 起始日期可能会在周四开始(比如2013年4月25日08:58:47.000)和结束日期(比如2013年4月28日20:58: 47.000),那么COMPDAYS应该是1.5天。不包括**完整的星期五和星期六** – 2013-04-28 07:52:40
您可能期望在两个日期之间有多大的天数 - 这个时间总是相对较小(比如不到一周),或者可能是几周/几个月/几年? – 2013-04-28 08:03:05
@WillA它可以不到一周;并可以超过一个星期....很少有可能去几个月..但不是几年 – 2013-04-28 09:50:50