【发布时间】:2012-02-07 22:09:27
【问题描述】:
我正在尝试为我的 SSRS 报告实现一个函数,该函数将根据三个日期的值返回一个颜色值:
Function SetBoxColor(dateOne As Date, dateTwo As Date, dateThree As Date) As String
' Determine colors for text box
If (dateOne Is Nothing) Then
SetBoxColor = "Blue"
Else
If (dateThree Is Nothing) Then
If dateOne >= Date.Now Then
If DateDiff("d",dateOne,Date.Now) < 90
SetBoxColor = "Yellow"
Else
SetBoxColor = "White"
End If
Else
SetBoxColor = "Orange"
End If
Else
If dateThree <= dateOne Or (Month(dateThree) = Month(dateOne) And Year(dateThree) = Year(dateOne)) Then
SetBoxColor = "Green"
Else
SetBoxColor = "Red"
End If
End If
End If
Return SetBoxColor
End Function
传递给此函数的参数是来自我的数据集的可空日期(SQL Server 日期类型),我从 TextBox 的 BackgroundColor 属性调用该函数:
=Code.SetBoxColor(Fields!dateOne.Value, Fields!dateTwo.Value, Fields!dateThree.Value)
按原样运行函数会返回错误:
“Is”需要具有引用类型的操作数,但该操作数的值类型为“Date”。
任何帮助将不胜感激。
【问题讨论】:
标签: vb.net reporting-services sql-server-2008-r2