Example 1 (Y2W)
SORT FIELDS=(10,6,Y2W,A) | * Sort C'mmddyy' in ascending order |
* with Y2W | |
* and previously set century window 1984-2083 |
The Full-Date Formats table above indicates that the 6-byte Y2W form is appropriate for a CH input field of the form xxxxyy. As shown in the following table, the output will be collated as C'yyyymmdd', with the non-date data (zeros) appearing correctly at the beginning of the sorted output.
Example 2 (Y2T)
SORT FIELDS=(20,5,Y2T,D) | * Sort Z'yyddd' in descending order |
* with Y2T | |
* and previously set century window 1921-2020 |
The Full-Date Formats table above indicates that the 5-byte Y2T form is appropriate for a ZD input field of the form yyddd. As shown in the following table, the output will be collated as Z'yyyyddd', with the non-date data (nines and zeros) appearing correctly at the beginning and end of the sorted output.
SORTIN Input |
Record Order after Sorting |
Actual Date after Sorting |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example 3 (Y2Y)
SORT FIELDS=(26,4,Y2Y,A) | * Sort P'mmddyy' in ascending order |
* with Y2Y | |
* and previously set century window 1921-2020 |
The Full-Date Formats table above indicates that the 4-byte Y2Y form is appropriate for a PD input field of the form xxxxyy. As shown in the following table, the output will be collated as P'yyyymmdd', with the non-date data (zeros and nines) appearing correctly at the beginning of the sorted output. Note that the first two columns are in hexadecimal.