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
 

 

Convert Date from CCYYMMDD to MMDDCCYY format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Sureet Mookherjee

New User


Joined: 08 May 2009
Posts: 19
Location: India

PostPosted: Tue Sep 22, 2009 2:37 pm    Post subject: Convert Date from CCYYMMDD to MMDDCCYY format
Reply with quote

I need to convert CCYYMMDD date format to MMDDCCYY format
How can i achieve this?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Sep 22, 2009 2:52 pm    Post subject:
Reply with quote

Ye gods, I'm not a programmer. I have not played COBOL in more than 25 years, but surely the logic below is oh so simple. Admittedly it may not be the most elegant or efficient, but surely you could have thought of something like this for yourself icon_rolleyes.gif

Code:

        03 OLD-DATE
           05 CCYY-O        PIC 9(4).
           05 MM-O          PIC 9(2).
           05 DD-O          PIC 9(2).
        03 NEW-DATE
           05 MM-N          PIC 9(2).
           05 DD-N          PIC 9(2).
           05 CCYY-N        PIC 9(4).


        MOVE ......................
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 22, 2009 3:41 pm    Post subject: Reply to: Convert Date from CCYYMMDD to MMDDCCYY format
Reply with quote

Or even..
Code:

Move A(1:4) to B(5:4)
Move A(5:2) to B(1:2)
Move A(7:2) to B(3:2)
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: Tue Sep 22, 2009 8:24 pm    Post subject:
Reply with quote

...or
Code:

01.
    05  CCYYMMDD    PIC  9(8).
    05  MMDDCCYY    PIC  9(8).
...
    MULTIPLY 10000.0001 BY CCYYMMDD GIVING MMDDCCYY.
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Wed Sep 23, 2009 12:34 pm    Post subject:
Reply with quote

Quote:
MULTIPLY 10000.0001 BY CCYYMMDD GIVING MMDDCCYY.

Hi Terry,
I didn't got how will this convert to the MMDDCCYY, could you please explain this?

thanks
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Sep 23, 2009 12:47 pm    Post subject:
Reply with quote

Hello Keten,

Please take an example of todays date in CCYYMMDD format (20090923)
If you multiply it by 10000.0001 you will get 200909232009.0923.since your field is defind as 9(8) it will truncate the values & you will get 09232009.

Hope it will help.
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Sep 30, 2009 1:20 am    Post subject: Reply to: Convert Date from CCYYMMDD to MMDDCCYY format
Reply with quote

I need to convert CCYYMMDD date format to MMDDCCYY format
How can i achieve this?

Example:

Code:
01 WS-A
    05 CCYY  PIC X(4).
    05 MM     PIC  X(2).
    05 DD     PIC  X(2).

02 WS-B.
    05 MM     PIC X(2).
    05 DD     PIC X(2).
    05 CCYY  PIC X(4)

MOVE CORRESPONDING WS-A
    TO WS-B


HOPE THIS WILL WORK

REGARDS,
XAVIER
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 Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
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


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