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
 

 

Cobol equivalent to the DB2 WHERE mydb2date

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

New User


Joined: 16 Sep 2008
Posts: 19
Location: illinois

PostPosted: Wed Nov 19, 2008 5:42 am    Post subject: Cobol equivalent to the DB2 WHERE mydb2date
Reply with quote

is there an equivalent to the DB2 WHERE mydb2date < (CURRENT_DATE + 3 MONTH) using cobol intrinsic functions and/or LE callable services?

I don't want to make a non db2 program a db2 program just for the date.
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: Wed Nov 19, 2008 6:38 am    Post subject: Re: another date question
Reply with quote

When this DB2 command is issued, does it add the number of days associated with each future month to CURRENT-DATE? Let's say, it's February thru April, which would be 28 (29 for leap year) 31 and 30?

You can build a month table, which contains the number of days associated with each month in each table-entry, multiply each chosen table-entry by 86400 (number of seconds in a day) and add them into a WS variable.

Then, use the LE Callable Service routine "CEESECS" to convert the CURRENT-DATE into seconds, add the above accumulated seconds to this seconds-value and use "CEEDATM" to convert this adjusted seconds-value into the target future date.

BTW, a lazy way icon_wink.gif to determine whether a given "February" is in a leap year is to call "CEEDAYS". If the feedback-halfword is ZERO, then it's a leap year. Otherwise, it's not.

Piece of cake. icon_eek.gif

HTH....

Regards,

Bill
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: Wed Nov 19, 2008 6:57 am    Post subject: Re: another date question
Reply with quote

Another thought using COBOL functions.

Convert the CURRENT-DATE to lilian-days (FUNCTION INTEGER-OF-DATE), add the accumulated days (from above post) to these lilian-days and then use FUNCTION DATE-OF-INTEGER (using the adjusted lilian-days), to calculate the future date.

This seems easier and less convoluted. icon_wink.gif

But remember, if for some reason CURRENT-DATE is invalid, the COBOL FUNCTION (unlike a call to an LE Callable Service routine), will crash and burn, which is one of the pitfalls of DATE FUNCTIONS. icon_eek.gif

Regards,

Bill
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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


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