Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 不包括星期五及;在SSRS中使用DATEDIFF函数时_Sql_Reporting Services_Ssrs 2008_Reportingservices 2005 - Fatal编程技术网

Sql 不包括星期五及;在SSRS中使用DATEDIFF函数时

Sql 不包括星期五及;在SSRS中使用DATEDIFF函数时,sql,reporting-services,ssrs-2008,reportingservices-2005,Sql,Reporting Services,Ssrs 2008,Reportingservices 2005,下面是我的SQL查询,用于计算两天之间的天数 SELECT count(*) as NoofCalls, outside.ReferenceNo, outside.WorkflowType, outside.Department, inside.CompletedDate, outside.CommentResponse, outside.CommentText, outside.CommentUserDisplayName, outside.StepName, outside.Ori

下面是我的
SQL
查询,用于计算两天之间的天数

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
我需要在计算CompDays时排除星期五和星期六

提前感谢您的帮助。

我自己修好了

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)) 
                             -(DATEDIFF(wk, outside.StartTime, inside.CompletedDate) * 2)
                             -(CASE WHEN DATENAME(dw, outside.StartTime) = 'Friday' THEN 1 ELSE 0 END)
                             -(CASE WHEN DATENAME(dw, inside.CompletedDate) = 'Saturday' THEN 1 ELSE 0 END)  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
ORDER BY               outside.ReferenceNo, outside.WorkflowType, outside.Department, outside.StartTime, inside.CompletedDate, outside.CommentResponse, outside.CommentText, 
    outside.CommentUserDisplayName, outside.StepName, outside.Originator, outside.Subject

使用SSRS 2005。开始日期可能从周四(比如2013-04-25 08:58:47.000)开始,结束日期(比如2013-04-28 20:58:47.000)结束,那么COMPDAYS应该是1.5天。不包括完整的星期五和星期六两个日期之间的天数-这总是相对较小(比如说,少于一周),还是可能是周/月/年?@WillA它可能少于一周;而且可能超过一周。。。。几个月内可能很少有人去。。但不是yearsHi,有人能帮我吗没有这个PLZI,有人能帮我这个plz吗