Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Example 19 z/OS DFSORT Application Programming Guide SC23-6878-00 |
|
This example illustrates how you can calculate the difference in days between two different types of date fields, each of which has separators. The SORTIN data set has these input records with a C'mm/dd/yy'
date field in positions 1-8 and a C'yy/ddd' date field in positions
11-16:
The OUTREC statement calculates the number of days for date1-date2 and puts the result in the output record in positions 1-8. The first IFTHEN clause removes the / separators from date1 and
date2 so we can use them in DATEDIFF. After the first IFTHEN clause,
the records look like this, with the C'mmddyy' date in positions 1-6
and the C'yyddd' date in positions 8-12:
The second IFTHEN clause uses DATEDIFF to get the number of days between date1 and date2. We use 1,6,Y2W to match the C'mmddyy' date and 8,5,Y2T to match the C'yyddd' date. SORTOUT will have these records:
Note that when date1>=date2, the result is a positive value, and when date1<date2, the result is a negative value. |
Copyright IBM Corporation 1990, 2014
|