View previous topic :: View next topic
|
Author |
Message |
Sureet Mookherjee
New User
Joined: 08 May 2009 Posts: 19 Location: India
|
|
|
|
I need to convert CCYYMMDD date format to MMDDCCYY format
How can i achieve this? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
...or
Code: |
01.
05 CCYYMMDD PIC 9(8).
05 MMDDCCYY PIC 9(8).
...
MULTIPLY 10000.0001 BY CCYYMMDD GIVING MMDDCCYY. |
|
|
Back to top |
|
|
Ketan Varhade
Active User
Joined: 29 Jun 2009 Posts: 197 Location: Mumbai
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
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 |
|
|
|