View previous topic :: View next topic
|
Author |
Message |
saji123
New User
Joined: 15 Jul 2009 Posts: 19 Location: Chennai
|
|
|
|
How to convert a date in yyyymmdd format to ccyymmdd format in cobol |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
saji123 wrote: |
How to convert a date in yyyymmdd format to ccyymmdd format in cobol |
What is the difference? |
|
Back to top |
|
|
saji123
New User
Joined: 15 Jul 2009 Posts: 19 Location: Chennai
|
|
|
|
Oh sorry !!! want to convert to ccyyddmm format |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Code: |
MOVE YYYYMMDD (1 : 4) TO CCYYDDMM (1 : 4).
MOVE YYYYMMDD (7 : 2) TO CCYYDDMM (5 : 2).
MOVE YYYYMMDD (5 : 2) TO CCYYDDMM (7 : 2).
|
Really difficult! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Regardless of the COBOL version, redefine the YYYYMMDD and CCYYDDMM as two group levels -
Code: |
03 WS-CCYYDDMM-X REDEFINES WS-CCYYDDMM.
05 WS-CCYY PIC 9(04).
05 WS-CCYY-DD PIC 9(02).
05 WS-CCYY-MM PIC 9(02).
03 WS-YYYYMMDD-X REDEFINES WS-YYYYMMDD.
05 WS-YYYY PIC 9(04).
05 WS-YYYY-MM PIC 9(02).
05 WS-YYYY-DD PIC 9(02).
MOVE WS-YYYY TO WS-CCYY.
MOVE WS-YYYY-MM TO WS-CCYY-MM.
MOVE WS-YYYY-DD TO WS-CCYY-DD.
|
Bill |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
...or
Code: |
03 WS-CCYYMMDD.
05 WS-CCYY PIC 9999.
05 WS-MM PIC 99.
05 WS-DD PIC 99.
03 WS-CCYYDDMM.
05 WS-CCYY PIC 9999.
05 WS-DD PIC 99.
05 WS-MM PIC 99.
MOVE CORRESPONDING WS-CCYYMMDD TO WS-CCYYDDMM. |
Ordinarily, I don't like the CORR option of MOVE statements, but I make an exception for date manipulation like this. The down side of this is that you must qualify the output field names if referenced in another part of the program. |
|
Back to top |
|
|
|