简体   繁体   English

是否有SSRS表达式可以计算两天之间的差异(周末,周六和周日除外)?

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

I'm able to calculate date difference between two dates, however, its include all weekends. 我可以计算两个日期之间的日期差,但是,它包括所有周末。 But I need difference excluding weekends like Saturday and Sunday. 但除了周六和周日这样的周末外,我需要有所不同。 I am using below expression: 我正在使用以下表达式:

=DateDiff("d", Fields!StartDate.Value,Fields!EndDate.Value) = DateDiff(“ d”,Fields!StartDate.Value,Fields!EndDate.Value)

To do this in SSRS, go to the report code window and add the below 要在SSRS中执行此操作,请转到报告代码窗口并添加以下内容

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

In the textbox where you need to display the value, add the below expression 在需要显示值的文本框中,添加以下表达式

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

Hope this helps you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM