IBM COBOL400 Question:
Download Questions PDF

How to Convert 2010/02/11 to m/dd/yyy.. with string and without string if any other method... code?

Answers:

Answer #1
The above issue can be resolved by using REDEFINES clause.

01 DATE-FIELD
05 DATE-YYYY PIC 9(04).
05 DATE-MM PIC 9(02).
05 DATE-DD PIC 9(02).
01 DATE-CONT REDEFINES DATE-FIELD
05 DATE-MM-CONT PIC 9(02).
05 DATE-DD-CONT PIC 9(02).
05 DATE-YYYY-CONT PIC 9(04).

I guess the above declaration will resolve it. I have not
tested it.

Answer #2
01 DATE-FIELD2 PIC X(10).
01 DATE-FIELD-RED REDEFINES DATE-FIELD2.
05 DATE-MM PIC X(02).
05 FILLER PIC X VALUE \\"/\\".
05 DATE-DD PIC X(02).
05 FILLER PIC X VALUE \\"/\\".
05 DATE-YYYY PIC X(04).
01 DATE-FIELD.
05 DATE-YYYY PIC X(04).
05 FILLER PIC X .
05 DATE-DD PIC X(02).
05 FILLER PIC X .
05 DATE-MM PIC X(02).
With string:

MOVE \\"2010/02/11\\" TO DATE-FIELD.
STRING DATE-MM DELIMITED BY SIZE
\\"/\\"
DATE-DD DELIMITED BY SIZE
\\"/\\"
DATE-YYYY DELIMITED BY SIZE
INTO DATE-FIELD2.
Without string:
MOVE \\"2010/02/11\\" TO DATE-FIELD.
MOVE CORR DATE-FIELD TO DATE-FIELD-RED.

Download IBM COBOL400 Interview Questions And Answers PDF

Previous QuestionNext Question
How to detect record is locked in Cobol/400?
Wat is the solution for that?
Code how to read 5th element of the array?