【发布时间】:2014-03-14 20:28:36
【问题描述】:
我有一个开始日期和一个结束日期,并且正在计算两者之间的工作日:
我创建了一个名为 CountWeekDays 的计算字段,它等于: Code.getBusinessDaysCount(Fields!date_created.Value,Fields!date_closed.Value)
我可以得到这样的平均值:=Avg(Fields!CountWeekDays.Value)
但是,我无法以同样的方式获得中位数。我怎样才能得到计算出来的东西的中位数?
我用来获取工作日计数的代码如下:
Function getBusinessDaysCount(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
【问题讨论】: