I need to create an SSRS (2017) report with date range parameters, BeginDate and EndDate.
Context: this is a report to pull names, birthdates, and deceased dates, based on the deceased date occurring between BeginDate and EndDate.
The table I am working with stores dates in a YYYYMMDD format.
Initially I tried the simple solution of setting the parameter to DateTime format. This did not work. I am assuming it is because the local language settings put the parameter format in MMDDYYYY so selecting 02172018 to 10172019 would not produce results if all the dates in the table start with 2019(mmdd).
I don't believe adjusting the language settings would not be beneficial in this instance in the long term as there will be multiple users in multiple locations running this report so I'm guessing it wouldn't work for everyone. I'm not authorized to change the language settings on my local server for this purpose either, so that's out.
If those assumptions not correct, please advise.
So then I thought maybe if I converted the dates within the report's main dataset that it might still read it, but that didn't work either:
CASE WHEN A.birthdate = '00000000'
THEN ''
ELSE CASE LEN(A.birthdate)
WHEN 8
THEN CONVERT(varchar(10), CAST(A.birthdate AS datetime),21)
WHEN 6
THEN CONVERT(varchar(10), SUBSTRING(A.birthdate,1,4)+'/'+SUBSTRING(A.birthdate,5,2),21)
WHEN 4
THEN CONVERT(varchar(10), A.birthdate,21)
ELSE NULL
END
END AS BirthDate
,CASE WHEN D.DECEASEDDATE = '00000000'
THEN ''
ELSE CASE LEN(D.DECEASEDDATE)
WHEN 8
THEN CONVERT(varchar(10), CAST(D.DECEASEDDATE AS datetime),21)
WHEN 6
THEN CONVERT(varchar(10), SUBSTRING(D.DECEASEDDATE,1,4)+'/'+SUBSTRING(D.DECEASEDDATE,5,2),21)
WHEN 4
THEN CONVERT(varchar(10), D.DECEASEDDATE,21)
ELSE NULL
END
END AS DeceasedDate
I got the following error:
"An error has occurred during report processing. Cannot read the next data row for the dataset. The conversion of a varchar data type to a datetime data type resulted in an out-of-range value."
What else can I try to get the date parameters to work?
CAST('20200219' AS date)
? Is that prevented by your configuration? – Cowthulhu