View previous topic :: View next topic
|
Author |
Message |
abhishek mitra
New User
Joined: 24 Feb 2008 Posts: 48 Location: Kolkata
|
|
|
|
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.
Thanks |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
abhishek mitra
New User
Joined: 24 Feb 2008 Posts: 48 Location: Kolkata
|
|
|
|
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 |
|
|
diwa_thilak
Active User
Joined: 13 Jul 2006 Posts: 205 Location: At my desk
|
|
|
|
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 |
|
|
arvind.m
Active User
Joined: 28 Aug 2008 Posts: 205 Location: Hyderabad
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
arvind.m
Active User
Joined: 28 Aug 2008 Posts: 205 Location: Hyderabad
|
|
|
|
Thank you CG. Can anyone provide link/document regarding the cobol functions. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
arvind.m
Active User
Joined: 28 Aug 2008 Posts: 205 Location: Hyderabad
|
|
|
|
Thank you. |
|
Back to top |
|
|
|