Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2504
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: 1249
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 Conversion of DLI update Jobs as BMP ... Gopinath Shanmugam IMS DB/DC 3 Wed Dec 20, 2017 12:02 pm
No new posts Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm
No new posts Conversion of UTF-8 to EBCDIC muralikrishnan_new COBOL Programming 1 Tue Nov 21, 2017 5:33 pm
No new posts Mainframe Blocks to Tracks conversion upendrasri JCL & VSAM 1 Sat Nov 18, 2017 10:52 am
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us