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

Cobol equivalent to the DB2 WHERE mydb2date


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 19, 2008 6:38 am
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 19, 2008 6:57 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top