I have two parameters that I’m working with:
Parameter 1:
Name: endYear
Prompt: endYear
Data Type: Integer
Available Values: Specify Values (Label: 2023-24 Value: 2024; Label: 2024-25 Value: 2025)
Default Values: None
Parameter 2:
Name: fromDate
Prompt: From
Data Type: Date/Time
Available Values: None
Default Values: Get Values from a query (Dataset: Dates Value Field: fromDate)
Dataset:
Name: Dates
Data Source: A sql server
Parameters: The value from Parameter 1 (endYear)
Stored Procedure: rptCompoundDates
SQL:
@endYear int (the incoming parameter being passed in)
DECLARE @today SMALLDATETIME = GETDATE()
SELECT CAST(MIN(d.date) AS DATE) fromDate,
CAST(IIF(MAX(d.date) < @today, MAX(d.date), IIF(@today < MIN(d.date), MIN(d.date), @today)) AS DATE) toDate
FROM jcps.dbo.Calendar cal
JOIN jcps.dbo.school sch ON sch.schoolID = cal.schoolID
AND sch.stateClassification = 'A1'
JOIN jcps.dbo.Day d ON d.calendarID = cal.calendarID
AND d.instruction = 1
WHERE cal.endYear = @endYear
I have tested the output of the sql by passing in @endYear = 2024 and @endYear 2025 and the expected dates are being passed back out.
When I run the report, since I don’t have a default end year selected, when I select either 2023-24 or 2024-25 the proper From date is returned and populates correctly Parameter 2 fromDate.
The problem is that when I select the other end year, it does not change the fromDate to be the correct value being passed in from the SQL, it remains whatever the original endYear value was. Can somebody tell me what I am doing wrong?
enter image description here
James Genslinger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.