View previous topic :: View next topic
|
Author |
Message |
xsray
New User
Joined: 16 Sep 2008 Posts: 19 Location: illinois
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 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.
HTH....
Regards,
Bill |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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.
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.
Regards,
Bill |
|
Back to top |
|
|
|