title: Checking for NULL dates in custom code function
body: <p>I am trying to implement a function for my SSRS report which will return a color value depending on the values of three dates:</p>
  
  
  
  <pre class="lang-vb prettyprint-override"><code>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 &gt;= Date.Now Then
          If DateDiff("d",dateOne,Date.Now) &lt; 90
            SetBoxColor = "Yellow"
          Else
            SetBoxColor = "White"
          End If
        Else
          SetBoxColor = "Orange"
        End If
      Else
        If dateThree &lt;= 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
  </code></pre>
  
  <p>The parameters passed to this function are nullable date (SQL Server date type) from my dataset and I call the function from a TextBox's BackgroundColor property as:</p>
  
  <pre class="lang-vb prettyprint-override"><code>=Code.SetBoxColor(Fields!dateOne.Value, Fields!dateTwo.Value, Fields!dateThree.Value)
  </code></pre>
  
  <p>Running the function as is returns the error:</p>
  
  <blockquote>
    <p>'Is' requires operands that have reference types, but this operand has the value type 'Date'.</p>
  </blockquote>
  
  <p>Any help would be appreciated.</p>