View previous topic :: View next topic
|
Author |
Message |
rajeevdas03 Warnings : 1 New User
Joined: 21 Jan 2006 Posts: 19 Location: Mumbai
|
|
|
|
Hi,
suppose we have date format like this;
01 ws-date pic x(6).
05 WS-MM PIC x(2).
05 WS-DD PIC x(2).
05 WS-YY PIC x(2).
i want this date in this format,
dd/mm/yy
please tell me how can we do this. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
Try some thing like -
Code: |
05 DATE-YYMMDD-IN.
10 DATE-OUT-YY PIC X(02) VALUE SPACES.
10 DATE-OUT-MM PIC X(02) VALUE SPACES.
10 DATE-OUT-DD PIC X(02) VALUE SPACES.
05 DATE-YYMMDD-OUT.
10 WS-RUN-DATE-MM PIC XX VALUE SPACES.
10 FILLER PIC X VALUE '/'.
10 WS-RUN-DATE-DD PIC XX VALUE SPACES.
10 FILLER PIC X VALUE '/'.
10 WS-RUN-DATE-YY PIC XX VALUE SPACES. |
Now, move DATE-YYMMDD-IN to DATE-YYMMDD-OUT. You might use REDEFINES.
Please use some suitable subject title, what does "COBOL" conveys to the reader..forum-name..!! |
|
Back to top |
|
|
Antonio Barata Warnings : 1 New User
Joined: 04 Apr 2007 Posts: 37 Location: Lisbon, Portugal
|
|
|
|
Hi Anuj
I think that your code won't work.
This will do what he wants:
01 ws-date pic x(6).
05 WS-MM PIC x(2).
05 WS-DD PIC x(2).
05 WS-YY PIC x(2).
01 ws-date-new pic x(6).
05 WS-DD PIC x(2).
05 FILLER PIC X(1) VALUE '/'.
05 WS-MM PIC x(2).
05 FILLER PIC X(1) VALUE '/'.
05 WS-YY PIC x(2).
MOVE CORRESPONDING ws-date TO ws-date-new.
regards |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Rajeev,
Quote: |
i want this date in this format,
dd/mm/yy |
You can use STRING for your requirement.
The Below code was not tested
Code: |
STRING
WS-DD DELIMITED BY SIZE
'/' DELIMITED BY SIZE
WS-MM DELIMITED BY SIZE
'/' DELIMITED BY SIZE
WS-YY DELIMITED BY SIZE
INTO destination
END-STRING
|
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
I've never used a PIC clause on '01' level..
Code: |
01 ws-date pic x(6). |
Further, this
Quote: |
move DATE-YYMMDD-IN to DATE-YYMMDD-OUT. |
from my post is not the part of "code", whatever way you want you can use for MOVing data from one varibale to another; CORRESPONDING or individual varible MOVE. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Antonio,
Quote: |
01 ws-date-new pic x(6). |
Check your post, you have used a PIC clause on a 01 level variable. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
rajeevdas03
DO NOT .......................
Post the same question twice
Use meaningless titles
You have been warned !!! |
|
Back to top |
|
|
Antonio Barata Warnings : 1 New User
Joined: 04 Apr 2007 Posts: 37 Location: Lisbon, Portugal
|
|
|
|
Quote: |
Check your post, you have used a PIC clause on a 01 level variable. |
Right
I just did a copy-paste, didn't even look at it and, when defining the new structure made the same mistake.
Sorry for that.
Here goes the correction:
Code: |
01 ws-date.
05 WS-MM PIC x(2).
05 WS-DD PIC x(2).
05 WS-YY PIC x(2).
01 ws-date-new.
05 WS-DD PIC x(2).
05 FILLER PIC X(1) VALUE '/'.
05 WS-MM PIC x(2).
05 FILLER PIC X(1) VALUE '/'.
05 WS-YY PIC x(2).
MOVE CORRESPONDING ws-date TO ws-date-new. |
I Think this time it is right.
Regards |
|
Back to top |
|
|
|