View previous topic :: View next topic
|
Author |
Message |
babu_hi
New User
Joined: 11 Apr 2006 Posts: 93
|
|
|
|
i want to get last date of current moanth in YYYYMMDD formant.
I am passing current month start date as "20091101" and the end date of month shold be return "20091131".
i have taken logic from this site which was mentioned in the below post.but that logic isnot working for me?please let me which is wrong in my program?
WORKING-STORAGE SECTION.
01 WS-CURRENT-DATE PIC 9(08) VALUE ZEROS.
01 WS-CURRENT-DATE-X REDEFINES WS-CURRENT-DATE.
05 WS-YYYY PIC 9(04).
05 WS-MM PIC 9(02).
05 WS-DD PIC 9(02).
01 LAST-DATE PIC 9(8) VALUE ZEROS.
PROCEDURE DIVISION.
0000-MAINLINE.
INITIALIZE WS-CURRENT-DATE
WS-CURRENT-DATE-X
LAST-DATE.
MOVE '20091101' TO WS-CURRENT-DATE.
DISPLAY "PASSED DATE : ", WS-CURRENT-DATE.
MOVE WS-CURRENT-DATE(1:4) TO WS-YYYY.
MOVE WS-CURRENT-DATE(5:2) TO WS-MM.
MOVE 01 TO WS-MM.
MOVE WS-CURRENT-DATE(7:2) TO WS-MM.
MOVE 01 TO WS-MM.
IF WS-MM > 12
MOVE 01 TO WS-DD
MOVE 01 TO WS-MM
END-IF.
MOVE WS-CURRENT-DATE-X TO WS-CURRENT-DATE.
COMPUTE WS-CURRENT-DATE =(FUNCTION DATE-OF-INTEGER
(FUNCTION INTEGER-OF-DATE(WS-CURRENT-DATE) + 1 )).
DISPLAY "WS-CURRENT-DATE : ", WS-CURRENT-DATE.
DISPLAY "LAST-DATE : ", LAST-DATE.
GOBACK. |
|
Back to top |
|
|
babu_hi
New User
Joined: 11 Apr 2006 Posts: 93
|
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
20091131 ? are you sure ?
The best solution is to calculate 1st day of next month -1, ths will always give you the last day of previous month.
Gerry |
|
Back to top |
|
|
babu_hi
New User
Joined: 11 Apr 2006 Posts: 93
|
|
|
|
sorry i mentioned the wrong date in my the above post, end dat of current month is 20091130. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Babu,
Quote: |
but that logic isnot working for me?please let me which is wrong in my program? |
It would be better if you could tell us what exactly is happening. "is not working" is too generic for any of us to help
Code: |
MOVE WS-CURRENT-DATE(5:2) TO WS-MM.
MOVE 01 TO WS-MM.
MOVE WS-CURRENT-DATE(7:2) TO WS-MM.
MOVE 01 TO WS-MM.
IF WS-MM > 12
MOVE 01 TO WS-DD
MOVE 01 TO WS-MM
END-IF. |
Probably you would like to revisit this part of the code. Are you sure this is what is mentioned in the link... Please verify once again...
*Note : It would be better if you could put the program code using the BBcode.. |
|
Back to top |
|
|
|