View previous topic :: View next topic
|
Author |
Message |
madishpa
New User
Joined: 18 May 2007 Posts: 28 Location: Hyderabad
|
|
|
|
Hi All,
I have 2 dates, say curr-date and prev-date.
I need to check the difference, if it is more than 6 years or not.
Though i have written the logic for this, i was wondering there is any intrinsic function to do this operation in Cobol.
Please could anyone advise.
Thanks
Pavan. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Try the manual for intrinsic functions. Link at the top of the page. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Though i have written the logic for this, |
You should not have, some of the power of Your organization should have told You
and all You' d have left to do would be the coding
since You have not told the logic we cannot help with the possible library functions
but without knowing Your organization standards for date calculations
here is a quick idea
just subtract 6 years from the current date ( year_part - 6 )
and then using the integer of date builtin compare with the previous one |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You can use COBOL DATE FUNCTIONS, introduced with COBOL/370 (nearly 20 years ago) or LE Callable Service routines, external to the VS/COBOL II compiler but integrated with the COBOL/370 compiler.
LE routines can come in handy if you need to validate (in your example) the previous-date (hopefully the current-date is reliable).
Search the board for "CEEDAYS" and how it can be used for date-validation as well as validating whether a particular date is or is not a leap year.
If you pass a bad date to a COBOL DATE FUNCTION (and this has always puzzled me), you'll crash and burn. But, under the covers, COBOL DATE FUNCTIONS use LE Callable Service routines.
One of those mysteries of life I suppose....
Bill |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
I would subtract 6 years from the current date and convert that result to an integer using FUNCTION INTEGER-OF-DATE. Convert your previous date to an integer using FUNCTION INTEGER-OF-DATE. Then a simple IF statement can determine if previous date is more than 6 years ago. |
|
Back to top |
|
|
|