• dianerstein 8713 (12/7/2016)


    I only want 1 parameter value that can be obtained from the query where the parameter value = '16-17'. However I want to include logic that will also pick the previous school year. In this case the previous school year is value = '15-16'.

    This is my goal since the logic is used in ssrs reports. If the parameter value would take in more than one value, the embedded subreports in the ssrs reports change would be extremely too high.

    Here is a horrible hack to derive the second string to be used in your WHERE condition:

    DECLARE @test1 VARCHAR(10) = '16-17';

    DECLARE @test2 VARCHAR(10) = STUFF(CAST(CAST(REPLACE(@test1, '-', '') AS INT) - 101 AS VARCHAR(9)), 3, 0, '-');

    SELECT

    @test1

    , @test2;

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.