Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to get month last of date of current month?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: how to get month last of date of current month?
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    Post subject:
Reply with quote

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

http://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: 1703
Location: Australia

PostPosted: Wed Nov 25, 2009 2:35 pm    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm
No new posts Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Validate the Date girishb2 DFSORT/ICETOOL 9 Tue Sep 19, 2017 1:12 am
No new posts Julian Date to CICS ABSTTIME blayek CICS 3 Wed Aug 30, 2017 11:15 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us