Blank Optional DateRange omits Null Date values

Hillary B
Hillary B used Ask the Experts™
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}
     isnull({Table.Date}) or not(isnull({Table.Date}) )

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

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

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



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.
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.

Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

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?

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!
Yeah, I don't see why the other formulas didn't work either.  I guess you can accept your last post as the solution.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial