Avatar of Hillary B
Hillary B
 asked on

Blank Optional DateRange omits Null Date values

This is very close to many other topics but not quite what I'm looking for.

I have an Optional date range param that is set up like this in my record selection.
(not(HasValue({?DateRange}))) OR ( isnull({Table.Date}) or {Table.Date} in {?DateRange} )

When the date range is entered, it runs records within that range as well as NULL dates. This works fine.
However, when the range is left blank, it only runs for non-NULL dates. If the date value is null, it get omitted from the results.

I have tried:
if HasValue({?DateRange}) then
   isnull({Table.Date}) or {Table.Date} in {?DateRange}
else true

As well as:
if HasValue({?DateRange}) then
   isnull({Table.Date}) or {Table.Date} in {?DateRange}
else
     isnull({Table.Date}) or not(isnull({Table.Date}) )


What can I do to get NULL dates when the param is left blank?

Thanks
Crystal Reports

Avatar of undefined
Last Comment
James0628

8/22/2022 - Mon
Mike McCracken

Is that the complete record selection formula?
If not please provide the full formula (preferably copy and paste it).

mlmcc
Hillary B

ASKER
The rest of the selection formula is just handling a few other optional parameters.

Here's the actual code... short and sweet.
(not(HasValue({?Name})) OR {Provider.Name} = {?Name} ) and
(not(HasValue({?Dept})) OR {Facilities.Department} = {?Dept} ) and
(not(HasValue({?Status})) OR {Facilities.Status} = {?Status} ) and
(not(HasValue({?DateRange})) OR ( isnull({Facilities.RetroDate} or {Facilities.RetroDate} in {?DateRange} ))

I've used this method for an optional date range param before with no problem but those reports dealt with data that always had a date value so NULL dates weren't an issue. This particular report I've had to modify for possible NULL dates and those blank dates will only display if the date param is filled in but not when left blank.

Thanks again.
James0628

This is probably a typo, but you don't have a closing ) on the IsNull for RetroDate.  If that is a typo, could you actually copy the formula from the CR formula editor and paste it in a post here (as mlmcc suggested), so we know that we're seeing the correct formula?

 Apart from that apparent typo, I don't see anything wrong with the formula that you posted, but if there's one mistake, there could be others.

 James
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Mike McCracken

Try changing the last line to

(not(HasValue({?DateRange})) OR  isnull({Facilities.RetroDate}) or {Facilities.RetroDate} in {?DateRange} )

ANother idea would be


(isnull({Facilities.RetroDate}) OR not(HasValue({?DateRange}))  or {Facilities.RetroDate} in {?DateRange} )

I see there are multiple tables, Is the Facilities table the main table?

mlmcc
ASKER CERTIFIED SOLUTION
Hillary B

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
James0628

Yeah, I don't see why the other formulas didn't work either.  I guess you can accept your last post as the solution.

 James