是否有用于计算除周末、周六和周日之外的两天之间差异的 SSRS 表达式?

Is there an SSRS expression for calculating difference between two days excluding weekends, Saturday and Sunday?

我能够计算两个日期之间的日期差异,但是,它包括所有周末。但我需要区别,不包括周六和周日这样的周末。我正在使用以下表达式:

=DateDiff("d",字段!StartDate.Value,字段!EndDate.Value)

要在 SSRS 中执行此操作,请转到报告代码 window 并添加以下内容

Function getWorkingDaysCount(ByVal tFrom As Date, ByVal tTo As Date) As Integer

    Dim tCount As Integer
    Dim tProcessDate As Date = tFrom
    For x as Integer= 1 To DateDiff(DateInterval.Day, tFrom, tTo) + 1
      If Not (tProcessDate.DayOfWeek = DayOfWeek.Saturday Or tProcessDate.DayOfWeek = DayOfWeek.Sunday) Then
        tCount = tCount + 1
      End If
      tProcessDate = DateAdd(DateInterval.Day, 1, tProcessDate)
    Next
    Return tCount

End Function

在需要显示值的文本框中,添加下面的表达式

=Code.getWorkingDaysCount(parameters!StartDate.Value,parameters!EndDate.Value)

希望对您有所帮助。