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

Difference b/w 2 dates is more than 6 yrs-intrinsic function


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
madishpa

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Fri Aug 05, 2011 9:26 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Aug 05, 2011 9:32 pm
Reply with quote

Try the manual for intrinsic functions. Link at the top of the page.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Aug 05, 2011 9:35 pm
Reply with quote

Quote:
Though i have written the logic for this,


You should not have, some of the power of Your organization should have told You icon_biggrin.gif

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Aug 05, 2011 9:50 pm
Reply with quote

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). icon_wink.gif

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. icon_eek.gif

One of those mysteries of life I suppose....

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 05, 2011 10:38 pm
Reply with quote

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
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 Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts Timestamp difference and its average ... DB2 11
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
Search our Forums:

Back to Top