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!

Nullvalue of a Date

Status
Not open for further replies.

dmeister

Programmer
Apr 9, 2002
4
CH
Hi everybody

I've got here a field in a report and a date value in the database. So, I want to show the field only when there is a value in the date field on the database. I know, I have to do it within a formula (object_visibility), but I don't know, how the if-statement has to look like.

How do I find out, if a date field on the database has a value or not? I tried some things, but they all didn't work (e.g. Converting the date field to a string and trim it and testing if the result is "").

I would be very happy, if someone could give me a hint.

Regards, Dominik
 
well you are correct to be concerned about null values since they will halt the operation of a formula if you are not looking for them.

there are two approaches to dealing with nulls.

1. Change them to a default value and look for those values.

In the case of a date...they can be automatically converted to a ridiculous date such as Jan 01, 1900.

Then in your formula you can look for these values.

In the Conditional suppress of the field you would write

totext({table.datefield},"ddMMyyyy") = "01011900";

2. You can leave them alone and test for them being null.

Personally this is what I do but you will find many people here that use the first method.

So if it is just a case of revealing a field if the field is NOT NULL it is simpley done by placing the following formula in the conditional suppress of the field itself

If not isnull({table.field} then
false
else
true;

Now sometimes you can be fooled by people putting "spaces" into the record It doesn't happen with dates too much but it certainly happens with string fields.

in the case of String fields I would always modify the formula as follows:

If not isnull({table.field} and len(trim({table.field})) > 0 then
false
else
true;

ALWAYS REMEMBER....in a report where you leave the nulls as nulls (ie you don't convert them to a default value)....ALWAYS test for the null first!!!!... The formula dies otherwise.

Why do I like to leave Nulls as Nulls?
1. Personal preference
2. What do you do if you don't want nulls converted to a specific value? Eg. often nulls are converted to zero if they are numbers....but zero may be a valid result and you would never know that data was missing.
3. Personal preference :)

hope this helps Jim Broadbent
 
Thank you very much. You really helped me. I also prefer to leave nulls as nulls :)

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top