Data validation for datetime parameters in SSRS


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: 10% [?]

About Tom

Christ follower, husband, father, technology and photography enthusiast. Attempting to live life out as a light in this world and stumbling at times in this fallen world. Got a topic you want to have me look into? Did I miss something in a post? Let me know. Just add a comment below.