|
midrange-l-request@xxxxxxxxxxxx wrote:
> 4. date math in CL (G Armour)
>
>I have a need, in CL, to add 7 days to the current date and store it in a
>variable. I do not want to call an RPG program. IBM commands and API
>calls are acceptable.
GA:
Date math can be _almost_ trivial in ILE CL with the CEE* APIs. Here's a basic
demo that has two in-parms for FromDate and NbrDays and one out-parm for
ResultDate. (It _ought_ to allow in-parms for date format and others, but it's
just for demo.) It does DMPCLPGM before returning so you can see variable
values:
---------------------------- Begin CL
pgm ( +
&FromDate +
&NbrDays +
&ResultDate +
)
dcl &FromDate *char 6
dcl &NbrDays *dec ( 3 )
dcl &ResultDate *char 6
dcl &RtnVal1 *char 4
dcl &RtnVal2 *char 4
dcl &PicStr *char 6 value( 'DDMMYY' )
callprc CEEDAYS ( +
&FromDate +
&PicStr +
&RtnVal1 +
*omit +
)
chgvar %bin( &RtnVal2 ) ( %bin(&RtnVal1) + &NbrDays )
callprc CEEDATE ( +
&RtnVal2 +
&PicStr +
&ResultDate +
*omit +
)
dmpclpgm
Exit:
return
endpgm
---------------------------- End CL
Just compile via CRTBNDCL mylib/TSTADDDAYS
Example CALL:
==> call tstadddays ( '210404' x'007F' ' ' )
The program takes FromDate and turns it into an integer via CEEDAYS. It adds
NbrDays to that to get a second integer. It turns the second integer back into
a ResultDate via CEEDATE. In this example CALL, it should add 7 days. Obviously
if the CALL is compiled, the ResultDate parm is more useful.
The date picture string -- PicStr -- is hard-coded to 'DDMMYY' but can be just
about as long and complicated as you want to make it as long as FromDate and
ResultDate are adjusted to match.
A variation of this program would let you input a date and two picture strings
(date formats), call the same two APIs, and show the result of switching from
one format to another. Would give experience with picture strings for these
APIs.
Tom
--
Tom Liotta
The PowerTech Group, Inc.
19426 68th Avenue South
Kent, WA 98032
Phone 253-872-7788 x313
Fax 253-872-7904
http://www.powertech.com
__________________________________________________________________
Introducing the New Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Netscape. Just the Net You Need.
New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.