Log In    |    Knowledge Base    |    4D Home
Tech Tip: Displaying a blank value instead of Null Dates or Null Times
Published On: July 16, 2009

Often an application should display a blank field or variable instead of a null date (!00/00/00!) or a null time (?00:00:00?). Consider the dialog below. It contains four date variables, four time variables, and a list box with arrays as the source. The colums of the list box are a longint column, a date column, and an alpha column for the display of times.

The time and date variable labelled 1 have their property "Blank if null" set to true. Those labelled 2 have the property set to false.

The code that initializes the dialog is shown below. Note for the alpha varaiables the String command is used with the new constants Blank if null date and Blank if null time to achieve the same effect as using the property for Date and Time variables.

Date_4:=String(!00/00/00!;Blank if null date )

Time_4:=String(?00:00:00?;Blank if null time )

List boxes behave differently from variables though. Null dates in date arrays are automaically displayed as blanks and there is no setting to make them display a Null date. However, since there is no time array in 4D, the third column was defined as a string array and initialized using the String command with the appropriate 4D constant. The code for the List Box displayed above follows, odd rows display the date and time, even rows display blank values. Note that the null values are automatically displayed as blank values in this case.

ARRAY DATE(Column2;10)
ARRAY STRING(15;Column3;10)

For ($Ndx;1;10)
    Case of
    : ($Ndx%2=0)
        Column3{$Ndx}:=String(?00:00:00?;Blank if null time )
        Column3{$Ndx}:=String(Current time;HH MM SS )
    End case
End for

Commented by Thomas Fitch on July 17, 2009 at 9:47 AM
Null dates and times occur in fields where values have not been entered. If !00/00/00! or ?00:00:00? were entered then it is no longer a null value. You can test this using the Is field value Null command:

This tech tip describes the behavior of Null values, not just any value that is !00/00/00! or ?00:00:00?.