Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting where date field is NULL

Status
Not open for further replies.

ctwilliams

Programmer
Feb 15, 2002
86
US
My report pulls from a view that contains an outer join on the date field... some of the items I'm reporting on have a date, others do not. I want to display all items regardless of the date, however if the item DOES have a date I want to be able to restrict it using a {?DaysBack} parameter. Here is my selection formula...

DateDiff (&quot;d&quot;,{rpt.MyDate},CurrentDate) <= {?DaysBack}

This formula works in restricting the date by the {?DaysBack} parameter, however it is not reporting the items that have NULL dates. I tried adding the following but it didn't work...

DateDiff (&quot;d&quot;,{rpt.MyDate},CurrentDate) <= {?DaysBack}
OR IsNull ({rpt.MyDate})
 
Put your null test first.

Also, go to file, options and make sure the &quot;Convert null field value to default&quot; option is NOT checked.

Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
dgillz: It matters that the null test is first??? I've never observed that, do you have an example? I couldn't get a different result.

re: &quot;DateDiff (&quot;d&quot;,{rpt.MyDate},CurrentDate) <= {?DaysBack}
OR IsNull ({rpt.MyDate})?&quot;

kai@informeddatadecisions.com
 
I h ave never experienced this either, but I have been told it matters on certain databases. Every time this question comes up the answer has been to test for nulls first. Usually, that works. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
I have also, particularly in btoreve databases, found inconsistent results with IsNull(). I have had to write a formula like the following instead:


IsNull({rpt.MyDate}) or
Length({rpt.MyDate})=0 or
DateDiff (&quot;d&quot;,{rpt.MyDate},CurrentDate) <= {?DaysBack}

Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
OK, thanks for the response, dgillz.

I think that you may be experiencing differences in how data is stored and/or returned from various data sources.

The obvious one that you know is the convert null to default setting, but also ODBC drivers can produce different results.

I'd like to document any examples you might come across.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top