When the SET Destination is a Date


If the source field is null, the destination date field is set to the null value for the date storage type of the destination field.

Source date

Date source fields are copied using conversion routines appropriate to the date type of the source and destination fields. The value of the source field is then copied to the corresponding common date parts of the destination field. For example, if the destination field contains date parts of century, year, month, day, and hour, and the source field contains date parts of day, hour, and minute, the copy operation copies only the day and hour parts of the source field to the day and hour parts of the destination field. The remaining parts are filled with null values.

Source alpha

Unless the source field is null, it must contain exactly 16 decimal digits, which are then converted into a packed decimal number intermediate form. The packed decimal number is then treated as a packed decimal Gregorian date with all date parts present, and the intermediate form is copied using a conversion routine appropriate to the date type of the destination field. A source field that contains something other than 16 digits causes a non-recoverable error to occur.

Source number

If the source field is negative, the destination field is set to the null value for the date type of the destination field.

Otherwise, the number is converted to an intermediate form, packed decimal number, padded with leading zeros or truncation on the left, so that the number of digits in the intermediate form matches the number of digits in the date parts of the destination field. The intermediate form is then treated as a Gregorian packed decimal date and is copied using a conversion routine appropriate to the date type of the destination field. Any assumed decimal positions in the source field are ignored, and the packed decimal number is processed as if it were an integer value.

Source logic

A Gregorian packed decimal date intermediate form is used. If the value of the source field is 1 (yes), the intermediate form is set to a value of all 1s. If the value of the source field is 0 (no), the intermediate form is set to a value of 0. If the value of the source field is blank, the intermediate form is set to a value of -1 (the null value for packed decimal dates). The intermediate form is then copied using a conversion routine appropriate to the date type of the destination field.

Source constant

A date constant must be exactly 16 characters in length, without leading or embedded blanks, and with trailing blanks. The 16 characters are treated as if they were a Gregorian alpha date of the form ccyymmddhhmmssth. However, only those characters of the date constant that are within the range of the date parts of the destination date field must be valid date values. For readability, the “unused” components of the date constant may be set to “-.” For example, if the destination field is a yymmdd field, a valid date constant representing March 15, 1988, would be --880315--------.

Date constants are copied using conversion routines appropriate to a Gregorian alpha date and the date type of the destination field.