I have an SSRS report which uses a @Year parameter, which is chosen by the user at run-time.
Fine, so far, but the SQL in the Data set Properties section contains a hard-coded date of '2010-08-31' , but, the year part of it needs to be the same as the @Year parameter which the user chooses. In other words, if you run the report in the year 2010 the results will be correct, but not if you run it now (in 2014).
The SQL at the moment is (miminum required):
SELECT DateDiff(Year, birth_dt, '2010-08-31')
--Date of Start of Academic Term
FROM table99
WHERE acad_period = @Year
...so my question is, what is the correct syntax for substituting the @Year value in place of '2010'?
EDIT : Please note that the actual format for the year is (eg) 12/13, 13/14
DateDiff()
returns the difference in years, irrespective of date. stackoverflow.com/questions/1572110/… – JC Ford