Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Conversion of date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Conversion of date
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    Post subject: Re: Conversion of date
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    Post subject: Conversion of date
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Aug 27, 2009 10:19 pm    Post subject: Reply to: Conversion of date
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: 1239
Location: Richfield, MN, USA

PostPosted: Fri Aug 28, 2009 6:41 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us