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
 
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: 8629
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 Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am
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 Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts Format Last Record differently from r... Learncoholic DFSORT/ICETOOL 5 Tue Oct 24, 2017 12:01 pm

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