Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2504
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: 2504
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 How to display offset thru cobol prog... tvinodkumar7 CICS 1 Sun Apr 22, 2018 8:42 pm
No new posts Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 4 Fri Apr 20, 2018 4:17 pm
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts Call COBOL or PLI with a click from w... vaibhav gs All Other Mainframe Topics 1 Mon Apr 16, 2018 7:29 pm
No new posts COBOL MVS options BiswajitDG COBOL Programming 8 Fri Apr 06, 2018 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us