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

Last day of the month


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 2146
Location: At my coffee table

PostPosted: Tue Mar 24, 2009 8:12 pm
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
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
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
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: 2146
Location: At my coffee table

PostPosted: Wed Mar 25, 2009 3:21 am
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
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: 3156
Location: Tucson AZ

PostPosted: Fri Mar 27, 2009 11:01 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Mar 27, 2009 11:02 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts Help, trying to use OVERLAY to get a ... DFSORT/ICETOOL 3
No new posts To get previous month from current ti... SYNCSORT 7
Search our Forums:

Back to Top