title: How to check for null values before doing .AddDays() in SSRS?
body: <p>I have the following as the value for my textbox in SSRS report:  </p>
  
  <pre><code>   =iif(IsNothing(Fields!MyDate.Value), "", Format(Fields!MyDate.Value.AddDays(30), "MMMM dd, yyyy"))
  </code></pre>
  
  <p>It gives me an "#Error" every time MyDate is null.</p>
  
  <p>How do i work around this?</p>
  
  <p>UPDATE:</p>
  
  <p>i wrote this custom function, it got rid of the error, but returns January 31, 0001 when null date is passed.</p>
  
  <pre><code>Public Shared Function NewDate(myDate as DateTime, days as integer) AS string
  IF ISNOTHING(myDate) OR ISDBNULL(myDate) Then
      NewDate = "        "
  ELSE
      NewDate = Format(myDate.AddDays(days), "MMMM dd, yyyy")
  END IF
  End Function 
  </code></pre>
  
  <p>@Matt Hamilton: DateAdd("d", 30,Fields!MyDate.Value)</p>