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
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 |
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 |
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 |
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 |
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 |
What is the difference between index and subscript?
What is difference between com and com3? Eg. s9(4) so what is the memory it will occupy com and com3.
How To Separate The Numerics From An Alphanumric Data Item Which Contains Both Alphabates And Numerics ?
how can u redefine picx(10) with pic 9(6).
How do we get current date from system with century?
What are the different types of condition in cobol and write their forms.
How to convert bunch of words in a line to relvant ASCII values?
What are the pertinent COBOL commands?
Can we dynamically increase the size of occurs clause? i.e In case I an not sure of the size of array and want to increase the size at run time.If yes , how?
hw to create 3 dimensional array & hw to access it?
what is MSGLEVEL?
What are differences between Static Call and Dynamic Call?
10 Answers IBM, KBC, Keane India Ltd, Verizon,