sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2012 Location: USA
|
|
|
|
Whenever either SORT utility, or any other software behavior becomes unclear, or available manuals might give more questions than answers, I always run some little test - just to verify the specific question, and nothing else of a bigger task.
Such test would also prevent others from reading the manuals in reverse order.
The SORT manual is saying only
Quote: |
When the unit is months or years, a valid output date will always be created. For example,
subtracting one month from a March 30th date will result in February 28th in a non-leap
year and February 29th in a leap year. |
This only means that any wrong result of date calculation is replaced with the nearest correct date value. There is no clue why one can suppose that under any circumstances the correct date 20200228 must be "corrected" to 20200229?
For myself this is clear both from the SORT manual statement, and from common sense. To be sure I usually run specific test to eliminate any doubts.
Code: |
//*=====================================================================
//SORT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
20190131
20190228
20190229
20190201
20190210
20190330
20190331
20190131
20190201
20190210
20190220
20190221
20190222
20190223
20190224
20190225
20190226
20190227
20190228
20190229
20190201
20190210
20190330
20190331
20190131
20190228
20190229
20190201
20190210
20190330
20190331
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC BUILD=(1,8,
X,1,8,Y4T,ADDMONS,+1,TOGREG=Y4T,
X,1,8,Y4T,ADDMONS,+12,TOGREG=Y4T,
X,1,8,Y4T,ADDMONS,+13,TOGREG=Y4T)
OUTFIL REMOVECC,
BUILD=(/,
1,8,
X,10,8,
X,19,8,
X,28,8,C' <== ADDMONS',
/,8X,
X,10,8,Y4T,LASTDAYM,TOGREG=Y4T,
X,19,8,Y4T,LASTDAYM,TOGREG=Y4T,
X,28,8,Y4T,LASTDAYM,TOGREG=Y4T,C' <== LASTDAYM'),
HEADER1=(C'YYYYMMDD +1 MONTH +12MONTH +13MONTH',
/,C'-------- -------- -------- --------')
//*=====================================================================
|
The result is exactly what I expected from the very beginning
Code: |
YYYYMMDD +1 MONTH +12MONTH +13MONTH
-------- -------- -------- --------
20190131 20190228 20200131 20200229 <== ADDMONS
20190228 20200131 20200229 <== LASTDAYM
20190228 20190328 20200228 20200328 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190229 99999999 99999999 99999999 <== ADDMONS
99999999 99999999 99999999 <== LASTDAYM
20190201 20190301 20200201 20200301 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190210 20190310 20200210 20200310 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190330 20190430 20200330 20200430 <== ADDMONS
20190430 20200331 20200430 <== LASTDAYM
20190331 20190430 20200331 20200430 <== ADDMONS
20190430 20200331 20200430 <== LASTDAYM
20190131 20190228 20200131 20200229 <== ADDMONS
20190228 20200131 20200229 <== LASTDAYM
20190201 20190301 20200201 20200301 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190210 20190310 20200210 20200310 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190220 20190320 20200220 20200320 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190221 20190321 20200221 20200321 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190222 20190322 20200222 20200322 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190223 20190323 20200223 20200323 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190224 20190324 20200224 20200324 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190225 20190325 20200225 20200325 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190226 20190326 20200226 20200326 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190227 20190327 20200227 20200327 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190228 20190328 20200228 20200328 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190229 99999999 99999999 99999999 <== ADDMONS
99999999 99999999 99999999 <== LASTDAYM
20190201 20190301 20200201 20200301 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190210 20190310 20200210 20200310 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190330 20190430 20200330 20200430 <== ADDMONS
20190430 20200331 20200430 <== LASTDAYM
20190331 20190430 20200331 20200430 <== ADDMONS
20190430 20200331 20200430 <== LASTDAYM
20190131 20190228 20200131 20200229 <== ADDMONS
20190228 20200131 20200229 <== LASTDAYM
20190228 20190328 20200228 20200328 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190229 99999999 99999999 99999999 <== ADDMONS
99999999 99999999 99999999 <== LASTDAYM
20190201 20190301 20200201 20200301 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190210 20190310 20200210 20200310 <== ADDMONS
20190331 20200229 20200331 <== LASTDAYM
20190330 20190430 20200330 20200430 <== ADDMONS
20190430 20200331 20200430 <== LASTDAYM
20190331 20190430 20200331 20200430 <== ADDMONS
20190430 20200331 20200430 <== LASTDAYM
|
I'm glad that my common sense matches completely with the official SORT manual. |
|