I have an SSRS report that queries the AS400. The query takes 2 parameters, start_date
and end_date
. So the report has two text type
parameters.
I am trying to take today's date (using the Today()
function), and do a DateDiff
of 60 days, and use that value as the default value.
Here are the complications:
- My
Start_Date
andEnd_Date
parameter in the dataset areinteger
type variables, notDateTime
. - That means, I cannot do a
DateAdd("d", -60, Today())
. Because then, that parameter is considered a date parameter, not an integer parameter. Passing that value to the query is not possible. - I cannot change the parameters' data type to
Date
. Again, the query is expecting an integer value. This is sending a date value (with / and everything). - I cannot cast the parameter in the query, because AS400 parameters are a PAIN to pass. So right now, the parameter is a
?
. There are 6 parameters in the query and are in the exact order as they are in the report. I don't know how aCAST
or aCONVERT
is going to work on a?
. - The
Start_Date
andEnd_Date
fields have this format:YYYYMMDD
Here is what I was thinking about doing:
- I was thinking of doing a
CAST
on today's year, today's month, and today's date toSTR
and then concatenate them all. - And then,
CAST
thatSTR
toINT
and adding -60.
But if I did that, I am left with a completely random number. It may be anything. For instance, today's date minus 60 days would be 20170650
, which is obviously not a valid date.
How do I do this? Do I get today's date, add -60 days, then convert it to Integer? When I try to do that, I get a greyed out empty parameter textbox when I run the report. I thought that would work, I don't know why it does not.
Any suggestions would be appreciated.
TL;DR:
How do I do a DateAdd
of -60 days to Today's date and convert it to YYYYMMDD format and pass it as an Integer
to the query?