I’m using Crystal Reports 12.0.0.683 where I use a parameter of type date and set to Allow Range Values. Than I want to use it in Record Selection Formula. I’m setting Include this value and using this selection formula:
(not HasValue({?PARAM_DATE}) OR
(
if HasLowerBound({?PARAM_DATE}) and HasUpperBound({?PARAM_DATE}) then
({VIEW_REPORT_1.DATE_DUE} > Minimum({?PARAM_DATE})) and
({VIEW_REPORT_1.DATE_DUE} < Maximum({?PARAM_DATE}))
else if HasLowerBound({?PARAM_DATE}) and not HasUpperBound({?PARAM_DATE}) then
({VIEW_REPORT_1.DATE_DUE} > Minimum({?PARAM_DATE}))
else if HasLowerBound({?PARAM_DATE}) and not HasUpperBound({?PARAM_DATE}) and IncludesLowerBound({?PARAM_DATE}) then
({VIEW_REPORT_1.DATE_DUE} >= Minimum({?PARAM_DATE}))
else if not HasLowerBound({?PARAM_DATE}) and HasUpperBound({?PARAM_DATE}) then
({VIEW_REPORT_1.DATE_DUE} < Maximum({?PARAM_DATE}))
else if not HasLowerBound({?PARAM_DATE}) and HasUpperBound({?PARAM_DATE}) and IncludesUpperBound({?PARAM_DATE}) then
({VIEW_REPORT_1.DATE_DUE} <= Maximum({?PARAM_DATE}))
))
I use IncludesUpperBound and IncludesLowerBound but it is still not selecting the right records.
For example, I have DATE_DUE 2012-03-30 and if I set the parameter 2012-03-30 and select include this value the records get filtered out.
What am I doing wrong?
You’re not using Less-Than-Or-Equals/Greater-Than-Or-Equals everywhere so it’s not going to include values which are equal to the max or min.
You can greatly simplify your code by doing this: