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
 

 

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

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

New User


Joined: 18 May 2007
Posts: 27
Location: Hyderabad

PostPosted: Fri Aug 05, 2011 9:26 pm    Post subject: Difference b/w 2 dates is more than 6 yrs-intrinsic function
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Aug 05, 2011 9:32 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Fri Aug 05, 2011 9:35 pm    Post subject: Reply to: Difference b/w 2 dates is more than 6 yrs-intrinsi
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Aug 05, 2011 9:50 pm    Post subject: Reply to: Difference b/w 2 dates is more than 6 yrs-intrinsi
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Fri Aug 05, 2011 10:38 pm    Post subject:
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    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
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm


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