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
 

 

Last day of the month

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
abhishek mitra

New User


Joined: 24 Feb 2008
Posts: 48
Location: Kolkata

PostPosted: Tue Mar 24, 2009 7:59 pm    Post subject: Last day of the month
Reply with quote

Hi,

Is there any way to find the date of the last day of current month by using cobol intrinsic functions.

It can greatly reduce the number of lines I have to code otherwise. icon_rolleyes.gif

Thanks
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Mar 24, 2009 8:12 pm    Post subject:
Reply with quote

How about, after setting DD to 1 and adding 1 to MM (checking for 13), INTEGER-OF-DATE and subtract 1 day and then DATE-OF-INTEGER for the last day of the month.
Back to top
View user's profile Send private message
abhishek mitra

New User


Joined: 24 Feb 2008
Posts: 48
Location: Kolkata

PostPosted: Tue Mar 24, 2009 8:22 pm    Post subject:
Reply with quote

CICS Guy wrote:
How about, after setting DD to 1 and adding 1 to MM (checking for 13), INTEGER-OF-DATE and subtract 1 day and then DATE-OF-INTEGER for the last day of the month.


Yes,

I think thats going to work.

I will first take the current date from my system, then would add one to MM, move 1 to DD and then subtract 1 day. that should work.

thanks
Back to top
View user's profile Send private message
diwa_thilak

Active User


Joined: 13 Jul 2006
Posts: 205
Location: At my desk

PostPosted: Wed Mar 25, 2009 1:58 am    Post subject:
Reply with quote

Wow CICS Guy that was a cute solution.

I was thinking about the DB2 query to retrieve the date. But great this is a very simplest way of handling this issue.
Back to top
View user's profile Send private message
arvind.m

Active User


Joined: 28 Aug 2008
Posts: 205
Location: Hyderabad

PostPosted: Wed Mar 25, 2009 3:00 am    Post subject:
Reply with quote

Hello CICS guy,

Quote:

adding 1 to MM (checking for 13),


i did not get this part of the sentence. can you tell what are you doing after setting 1 to DD.

Thanks,
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Mar 25, 2009 3:21 am    Post subject:
Reply with quote

The input to the function is in the form of YYYYMMDD, redefine that into 3 variables, YYYY, MM & DD.
The output to the function is 9(7).
Move 01 to DD.
Add 1 to MM, if MM > 12, move 01 to MM and add 1 to YYYY.
Call function using
Compute YYYYMMDD = DATE-OF-INTEGER(INTEGER-OF-DATE(YYYYMMDD) - 1).
I think that should work.....
Or, compute 9(7) = INTEGER-OF-DATE(YYYYMMDD) - 1
and, compute YYYYMMDD = DATE-OF-INTEGER(9(7)).
Back to top
View user's profile Send private message
arvind.m

Active User


Joined: 28 Aug 2008
Posts: 205
Location: Hyderabad

PostPosted: Fri Mar 27, 2009 10:55 pm    Post subject:
Reply with quote

Thank you CG. Can anyone provide link/document regarding the cobol functions.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Mar 27, 2009 11:01 pm    Post subject:
Reply with quote

Click IBM Manuals at the top of the page and then click ENTERPRISE COBOL Language Reference for the manual.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7932
Location: Bellevue, IA

PostPosted: Fri Mar 27, 2009 11:02 pm    Post subject:
Reply with quote

The manuals link at the top of the page ... Enterprise COBOL Language Reference, chapter 7.1, Intrinsic Functions lists them all with arguments required.
Back to top
View user's profile Send private message
arvind.m

Active User


Joined: 28 Aug 2008
Posts: 205
Location: Hyderabad

PostPosted: Fri Mar 27, 2009 11:22 pm    Post subject:
Reply with quote

Thank you.
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
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
No new posts Retrieve current year or month using ... vnktrrd DFSORT/ICETOOL 15 Tue Mar 15, 2016 4:14 pm
No new posts Find list of all TSO users who used i... newroad CA Products 2 Fri Nov 06, 2015 12:01 am
No new posts Find and replace YccyyMmm to previous... santosh_g DFSORT/ICETOOL 5 Fri Oct 09, 2015 1:19 am


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