Author: Bill Woodger
Subject: Reply to: Two digit Date format
Posted: Sat May 07, 2016 2:11 pm (GMT 5.5)
If your data are reliable, it is even simpler:
I normally define date-fields as PIC X. Here I have 99 for the DD and MM as I want the leading-zero-fill which is automatically associated with a MOVE to a numeric field (the UNSTRING ends up using the same rules as MOVE).
Note that the YYYY is PIC X because I don't want the properties of a numeric for a MOVE. I want left-justified and right-truncation.
If desperate for some odd reason to use 9s for the YYYY, include an additional value (SPACE) on the DELIMITED BY.
Subject: Reply to: Two digit Date format
Posted: Sat May 07, 2016 2:11 pm (GMT 5.5)
If your data are reliable, it is even simpler:
Code: |
01 SOURCE-FIELD PIC X(30) VALUE "1/1/2016". 01 RESULT-FIELD. 05 RF-DD PIC 99. 05 FILLER PIC X VALUE "/". 05 RF-MM PIC 99. 05 FILLER PIC X VALUE "/". 05 RF-YYYY PIC XXXX. ... UNSTRING SOURCE-FIELD DELIMITED BY "/" INTO RF-DD RF-MM RF-YYYY |
I normally define date-fields as PIC X. Here I have 99 for the DD and MM as I want the leading-zero-fill which is automatically associated with a MOVE to a numeric field (the UNSTRING ends up using the same rules as MOVE).
Note that the YYYY is PIC X because I don't want the properties of a numeric for a MOVE. I want left-justified and right-truncation.
If desperate for some odd reason to use 9s for the YYYY, include an additional value (SPACE) on the DELIMITED BY.