Avatar of nsehmi
nsehmi
Flag for United States of America

asked on 

Add a IF ELSE Statement Based on Date Range in SSRS IN VBSCRIPT

Here is a VBSCRIPT that i put in SQL SERVER REPORTING SERVICES WHERE IT splits the info coming from the column MODFIEDFIELDS

Example: 1.Active=Active/Inactive<br>2.Group.....

The function below takes the ModfiedField COLUMN and splits it!

Public Function validate1(ByVal str, ByVal condition)

        Dim mod1 As String
        Dim array() As String
        mod1 = str
        array = Split(mod1, "<br>")
        Dim array2() As String
        Dim index As Integer
        Dim retValue As String
        For index = 0 To array.Length - 2
            mod1 = array(index)
            array2 = Split(array(index))

            If ((array2(0).Contains("FirstName")) Or (array2(0).Contains("LastName")) Or (array2(0).Contains("MiddleName"))) Then
                If (condition = 1) Then
                    Return "Name Change"
                End If
            ElseIf (array2(0).Contains("Address1")) Then
                If (condition = 1) Then
                    Return "Address Change"
                End If
            ElseIf (array2(0).Contains("HourlySalary")) Then
                If (condition = 1) Then
                    Return "Change of Pay"
                End If
            Else
                retValue = "NONE"
            End If
        Next
        Return "NONE"
    End Function

I want to add a logic in it where if it sees that the column (CREATEDON) falls under the DATE RANGE i have in SSRS, it should shoot out "New Hire"

The main challenge is that how do i connect the code to read 2 columns, as well as how can the logic determine if its under the @startdate and @endate range and shows "New Hire"

Currently the code in SSRS says.

=Code.Validate1(Fields!ModfiedFields.Value,1)

I need to connect that to Created on... as well as the New Hire Logic!
Microsoft DevelopmentDB Reporting Tools

Avatar of undefined
Last Comment
Tone' Shelby

8/22/2022 - Mon