how to display date in reverse order if the pic clause of
the is numeric
suppose date is 09032010 ==> need to print in 20100309
(pic clause is numeric)

Answers were Sorted based on User's Feedback



how to display date in reverse order if the pic clause of the is numeric suppose date is 0903201..

Answer / reshma j.

INPUT-DATE has value of 09032010.

In working storage:
01 INPUT-DATE.
03 MM1 PIC 9(2).
03 DD1 PIC 9(2).
03 CCYY1 PIC 9(4).

01 PRINT-DATE.
03 CCYY2 PIC 9(4).
03 DD2 PIC 9(2).
03 MM2 PIC 9(2).

In Procedure Division:

MOVE MM1 TO MM2.
MOVE DD1 TO DD2.
MOVE CCYY1 TO CCYY2.

After Moving values,PRINT-DATE value will be 20100309.
In this cond,Its totally depend on how we declare format in
working storage section.

plz let me know,if i m wrong.

Is This Answer Correct ?    14 Yes 1 No

how to display date in reverse order if the pic clause of the is numeric suppose date is 0903201..

Answer / tata

id division.
program-id. exe.
data division.
working-storage section.
01 idate pic 9(8) value 10032010.
01 rdate pic 9(8).
procedure division.
move idate (1:2) to rdate (7:2).
move idate (3:2) to rdate(5:2).
move idate (5:4) to rdate(1:4).
display rdate.
stop run.

Is This Answer Correct ?    10 Yes 0 No

how to display date in reverse order if the pic clause of the is numeric suppose date is 0903201..

Answer / mf123

Thanks Reshma, ur absolutely correct,

Is This Answer Correct ?    6 Yes 1 No

how to display date in reverse order if the pic clause of the is numeric suppose date is 0903201..

Answer / rajesh

Both the answers are correct. But if we want to use the date
or month or year value alone in somewhere in our program
then we can go with Reshma's explanation.

Is This Answer Correct ?    3 Yes 1 No

how to display date in reverse order if the pic clause of the is numeric suppose date is 0903201..

Answer / nanda

*********************** Top of Data ****
ID DIVISION.
PROGRAM-ID. ALLINONE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATE1.
05 DD PIC 9(2).
05 MM PIC 9(2).
05 YY PIC 9(4).
01 WS-DATE2.
05 YY PIC 9(4).
05 MM PIC 9(2).
05 DD PIC 9(2).
PROCEDURE DIVISION.
ACCEPT WS-DATE1.
MOVE CORR WS-DATE1 TO WS-DATE2.
DISPLAY WS-DATE1.
DISPLAY WS-DATE2.

STOP RUN.

Is This Answer Correct ?    1 Yes 0 No

how to display date in reverse order if the pic clause of the is numeric suppose date is 0903201..

Answer / aruna

both the ans are coreect.in reshma's ans directly we can
write corr mve statement behalf of those 3move
statements.simply we can write move corr input-date to
output-date.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More COBOL Interview Questions

Sending data is aplhabetic size 7 (value 3000), I wantated this value to be stored in database, which is defined as s9(7)v9(2)comp-3.

2 Answers  


Our issue is there seems to be a disconnect, or no link, between our SELECT statement and our SD. We had SELECT SORT-FILE and SELECT SORT-FILE ASSIGN TO SORTWRK. ASSIGN TO SORTWRK1 SORTWRK2 SORTWRK3 SORTWRK4. with SD SORT_FILE RECORD CONTAINS 7833 CHARACTERS. In either case, at run time, the system ignored our SORTWRK# DD statements and allocated 16 sort works with the SORTWK## naming convention. Any ideas why the system does not recognize the connection? We do not even need the SORTWRK DD statements. Thanks

0 Answers  


Which of the following EDITind and PICTURE symbols is to be used if a minus(-) is to appear before the value if the value is -ve and a plus(+) is to appear before the value if the value is +ve? (a) + (b) - (c) + OR (d) It is not possible

7 Answers   TCS,


Can we call a CICS program from a batch program or viceversa?If so, how?

3 Answers  


what is label record is standard or omitted in file description of data division?

3 Answers   IBM, TCS,






What is report-item?

1 Answers   IBM,


what is the minimum number of lines a Cobol program should have to successfully compile and run

11 Answers   ABC, Societe Generale,


where will we code call by content and call by reference dude pls reply soon ?

2 Answers  


What is different between variable length and fixed length?

2 Answers   TCS,


What is the local-storage section?

0 Answers  


have in 100 records in a file i want to read first 3 records and skip next 3 records and agan i want to read 3 records and again i want to skip 3 records...

2 Answers   ITC Indian Tobacco Company, PNP, TCS,


in cobol i have one file it contains records like 10,4,23,98,7,90..... total records 100. iwant 10 to 20 in reverse order in cobol environ ment any one please give the answer......

2 Answers   IBM,


Categories