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
Hillary BAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

mlmcc
0
Hillary BAuthor Commented:
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.
0
James0628Commented:
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
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

mlmccCommented:
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
0
Hillary BAuthor Commented:
James, it was a typo. I must have accidentally deleted that closing ) when I was replacing the table and fieldnames with something much shorter and simpler.

Unfortunately, that did not work either. It looked promising, and I fiddled with different variations of that, but I get the same results. No NULL dates unless I put something in the parameter.

What I did figure out is that even though I have no Default values set for this parameter it is never truly empty. I put the Min and Max of the range in a label at the top of the report just to see what was being evaluated and when left blank, the parameter has a 1/1/1901-1/1/2101 value.  

So I did this and it Works!
(
if Minimum({?DateRange}) <> date(1901, 01,01) or Maximum({?DateRange}) <> date(2101,01,01) then
    isnull({Facilities.RetroDate})  or  {Facilities.RetroDate} in {?DateRange}
 else (true)
)

I made the IF statement use an OR between the Min and Max in case the user only puts in one date for their search.
Still not sure why it wasn't pulling null dates if it always thought the parameter had a value but this works for some reason.

Thanks for your help!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James0628Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.