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: 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 How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm


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