× 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.



A variation on this that does not need the picture string or the input date variable in CEEDAYS is to use CEELOCT - the &RtnVal1 is one of 3 different date values, including the number of days since 1582 something, the number of seconds since that date (unusable in CL, as is floating point), and a character representation as 'YYYYMMDDHHMISSmmm000000'. Just a thought. Don't know which is more efficent, but for a single call, who cares that much?

Vern

At 02:54 PM 4/21/2004, you wrote:
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
_______________________________________________
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.