× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Dwayne,


Can you add to system date in a cl, if so how? We capture the system date and than we would like to add a day or two to it.



This is REALLY easy to do in ILE RPG. I'll assume that you want a pure CL solution, since if it was RPG you'd already know how to do it.



In my opinion, the best way to do this in CL is to convert it to a lilian date. A lilian date is a count of days since Oct 14, 1582 (the start of the gregorian calendar) so once you've created a lilian date, it's really simple to add & subtract days just by adding and subtracting numbers.


Once you've done the math, you can just convert it back to a "normal" date so that you can display it to the user, or use it in other calculations, whatever you want to do with it.

IBM provides APIs that convert to & from lilian format. The only "catch" is that you have to call them from an ILE language. In this case, ILE CL. So the source member type (used by PDM) in this case will be CLLE, and you'll compile the program with CRTBNDCL.

Here's a sample:

PGM

     DCL VAR(&QDATE) TYPE(*CHAR) LEN(6)
     DCL VAR(&YYMD)  TYPE(*CHAR) LEN(8)
     DCL VAR(&LILIAN) TYPE(*CHAR) LEN(4)

     /* GET THE CURRENT DATE IN YYYYMMDD FORMAT */

     RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&QDATE)
     CVTDAT     DATE(&QDATE) TOVAR(&YYMD) FROMFMT(*SYSVAL) +
                  TOFMT(*YYMD) TOSEP(*NONE)


/* USE THE CEEDAYS API TO CONVERT TO A LILIAN DATE, + ADD 1 DAY. + USE THE CEEDATE API TO CONVERT BACK TO YYYYMMDD */

     CALLPRC PRC(CEEDAYS) PARM(&YYMD 'YYYYMMDD' &LILIAN *OMIT)
     CHGVAR VAR(%BIN(&LILIAN)) VALUE(%BIN(&LILIAN) + 1)
     CALLPRC PRC(CEEDATE) PARM(&LILIAN 'YYYYMMDD' &YYMD *OMIT)


/* SHOW THE RESULT */

     SNDPGMMSG  MSGID(CPF9897) MSGF(QCPFMSG) +
                  MSGDTA('Tomorrow will be' *BCAT &YYMD) +
                  MSGTYPE(*COMP)

ENDPGM


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.