What do you mean by “Natural date”? A D-format field? A System variable?
These fields are an internal representation of a date, where 1 is the beginning of time and 732877 is today, 7/21/06. The format is specified via edit mask; the default format is specified by Natural’s DTFORM parameter.
Internally D fields are considered P6 format, so I validate them with values in the range 577813 (1/1/1582) through 986153 (12/31/2699).
Ralph, thanks for your reply. Yes, I am referring to D-format fields.
Near as I can tell the field is 4 bytes long. Now suppose the subroutine is passed spaces, X’40404040’, in the #DATE-IN area, how do I test that the format is correct or not for a D-format field.
I did try “IF #DATE-IN-P = MASK(NNNZ)” but it didn’t appear to work correctly. Do you have a line of code you would use for this test ?
The purpose of the IS operator is not to check whether the contents of a variable is in a specific format, but to check, whether the function VAL can transfer the value into a target of that format. As VAL only operates on alpha fields, also the left side of IS must be an alpha field.
See this code where the wrong usage of IS may lead to interesting results:
DEFINE DATA LOCAL
1 ALPHAVAR (A10)
1 REDEFINE ALPHAVAR
2 NUMVAR (N10)
END-DEFINE
INPUT ALPHAVAR
IF ALPHAVAR IS (N10)
ADD 0 TO NUMVAR
ELSE
RESET NUMVAR
END-IF
DISPLAY NUMVAR
END
Watch the result if alphavar contains the value ‘1’!