IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Conversion of date


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
saji123

New User


Joined: 15 Jul 2009
Posts: 19
Location: Chennai

PostPosted: Thu Aug 27, 2009 8:34 pm
Reply with quote

How to convert a date in yyyymmdd format to ccyymmdd format in cobol
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Aug 27, 2009 8:54 pm
Reply with quote

saji123 wrote:
How to convert a date in yyyymmdd format to ccyymmdd format in cobol


What is the difference?
Back to top
View user's profile Send private message
saji123

New User


Joined: 15 Jul 2009
Posts: 19
Location: Chennai

PostPosted: Thu Aug 27, 2009 9:39 pm
Reply with quote

Oh sorry !!! want to convert to ccyyddmm format
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Aug 27, 2009 10:11 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Aug 27, 2009 10:19 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 6:41 am
Reply with quote

...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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top