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

Convert Date from CCYYMMDD to MMDDCCYY format


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Sep 22, 2009 2:52 pm
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
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
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
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: 1208
Location: Bangalore,India

PostPosted: Wed Sep 23, 2009 12:47 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
Search our Forums:

Back to Top