Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us