VALIDATE(*NODATETIME)

The VALIDATE keyword specifies whether Date, Time and Timestamp data must be validated before it is used.

If this keyword is not specified, then Date, Time and Timestamp data is validated before it is used.

If *NODATETIME is specified, the compiler may omit performing validation for Date, Time and Timestamp data before it is used.

Specifying this keyword may improve the performance of the RPG program. In some cases, the compiler may be able to treat the Date, Time, or Timestamp data as though it was Alphanumeric data, avoiding the costly operations that deal with true Date, Time and Timestamp data.

Some examples of validations that will be omitted with VALIDATE(*NODATETIME):
  • When Timestamp fields are being used in comparison, sort or search operations, the Timestamp fields will be not be validated during the comparison.
  • When Date fields with date-format *ISO or *JIS are being used in comparison, sort or search operations, the Date fields will not be validated during the comparison.
  • When Time fields with a time-format other than *USA are being used in comparison, sort or search operations, the Time fields not be validated during the comparison.
  • When Date, Time, or Timestamp data is being assigned, and the formats and separators of the source and target are the same, the source will not be validated before the assignment. This applies to assignment operations, assignments to temporary values for parameters passed by constant reference and parameters passed by value, the RETURN operation, field moves for Input specifications, and field moves for Output specifications.
  • When Date, Time, or Timestamp data is being compared for Match Field or Control Level processing, the data will not be validated if it has *ISO format.
CAUTION:

When validation is not done, incorrect data will not be detected.

Use this keyword only if you are confident that the data in all your date, time, and timestamp fields is always valid. For example, if you have a data structure that has the default initialization of blanks, the date, time, and timestamp subfields will be initialized with the invalid value of blanks. If you specify VALIDATE(*NODATETIME), and use any of these subfields, the invalid data will be used in the operation, and it may be propagated to other fields in your program through assignments, or you may get meaningless results for comparison operations.

This warning applies even for Date, Time and Timestamp operations that do not appear in the list of the validations that will be omitted. In the future, additional validations may be omitted when VALIDATE(*NODATETIME) is specified.

Recommendations:
  • If you are confident that your Date, Time and Timestamp data is always valid, then
    • Where possible, use the *ISO or *JIS format for Date fields, and a format other than *USA for Time fields. This will allow operations involving comparisons and assignment to be done as though the data were alphanumeric.
    • Otherwise, use the same format for all Date and Time fields where possible. This will allow operations involving assignment to be done as though the data were alphanumeric.
  • If you are not confident that your Date, Time and timestamp data is always valid, do not specify the VALIDATE(*NODATETIME) keyword. This keyword is only intended to eliminate unnecessary validations. It is not intended to allow incorrect Date, Time, or Timestamp data to be used without error.