Tech4Him – Technology with Integrity

A Christian technology chaos wrangler and his thoughts

Data validation for datetime parameters in SSRS

Posted by Tom On July - 6 - 2009

Data validation for datetime parameter in SSRS.

Came across this piece of code for ensuring the end date comes after the start date.  Just what I was about to write but a quick Google search saved a bit of time. Yay!

The function below checks for the Start and End date ranges .

Function:

Function CheckDateParameters(StartDate as Date, EndDate as Date) as Integer
Dim msg as String
     msg = ""
     If (StartDate > EndDate)  Then
        msg="Start Date should not be later than End Date"
     End If
     If msg <> "" Then
        MsgBox(msg, 16, "Report Validation")
        Err.Raise(6,Report)                    'Raise an overflow
     End If
End Function

Steps:

1.) Go the Report Parameters and add a parameter with the datatype is string.

2.) Check the Hidden checkbox and Allow blank value ckeckbox.

3.) From Default Values choose Non-Queried radio button and then press the FX button and paste this code.

=CODE.CheckDateParameters(<parameterStartdate>.Value,<parameterEnddate>.Value)

Then press OK.

Blessings.

Popularity: 15% [?]

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • LinkedIn
  • PDF
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Leave a Reply