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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm

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