Page 1 of 1

Change the date display format.

Posted: Tue Dec 17, 2013 2:45 pm
by Maulik
Hi,

In a file I have a date in the format (ccyymmdd) and I need to create another file using this which in the format YYYYMon. Where "mon" is three letter representation of Month in words.

For example: if Input file has: 20130820the output should be 2013AUG. How do I do it? Please help.

Re: Change the date display format.

Posted: Tue Dec 17, 2013 3:00 pm
by zprogrammer
Move the DATE to a structure like below

Code: Select all

01 WS-DATE.
     05 WS-YEAR                      PIC X(04).
     05 WS-MON                       PIC X(02).
     05 WS-DAY                       PIC X(02).

01 WS-DATE2.
     05 WS-YEAR2                     PIC X(04).
     05 WS-MON2                      PIC X(03).


You could use EVALUATE to acheive the following

Code: Select all

EVALUATE WS-MON
                 WHEN "01"      
                           MOVE WS-YEAR TO WS-YEAR2
                           MOVE 'JAN'        TO WS-MON2
                 WHEN "02"      
                           MOVE WS-YEAR TO WS-YEAR2
                           MOVE 'FEB'        TO WS-MON2
                  ..
                 WHEN "12"      
                           MOVE WS-YEAR TO WS-YEAR2
                           MOVE 'DEC'        TO WS-MON2
                 WHEN OTHER      
                           PERFORM ERROR
END-EVALUATE

Re: Change the date display format.

Posted: Wed Dec 18, 2013 1:49 pm
by Maulik
Thanks Pandora-Box, this helps and I get the code written that way. I'm testing it and let you how I progress.

Re: Change the date display format.

Posted: Wed Dec 18, 2013 1:52 pm
by Maulik
Hi Enrico,

Thanks for the pointer - this is a new project for the team and no one was aware of such a routine. Though now we came to know about a in house date-routine and I think I've two solution for this problem now... :)

This is a great help. Thanks for your time.