IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to get month last of date of current month?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Wed Nov 25, 2009 2:21 pm
Reply with quote

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
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Wed Nov 25, 2009 2:25 pm
Reply with quote

the post which i have taken as a reference in the below link

www.ibmmainframes.com/viewtopic.php?t=39153&start=0&postdays=0&postorder=asc&highlight=
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Nov 25, 2009 2:35 pm
Reply with quote

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
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Wed Nov 25, 2009 2:45 pm
Reply with quote

sorry i mentioned the wrong date in my the above post, end dat of current month is 20091130.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Nov 25, 2009 8:59 pm
Reply with quote

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.. icon_wink.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts To get the the current time DFSORT/ICETOOL 13
Search our Forums:

Back to Top