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



If you wish to stay within CL you might consider converting the date to *JUL
or *LONGJUL and adding your days, then converting that julian date back to
your desired format.
The julian date field needs to be changed to a *DEC intermediate field to do
the addition.
Monitor for an invalid date.  If the date is invalid then you've gone over
year end and need to add 1000 to the julian date and then subtract 365 or
366 (depending on whether or not its a leap year).

This may not be attractive but it works.
 
---------------------------------
Booth Martin
http://www.martinvt.com
---------------------------------
-------Original Message-------
 
From: Midrange Systems Technical Discussion
Date: 04/21/04 15:46:58
To: Midrange Systems Technical Discussion
Subject: Re: date math in CL
 
Charles, Vern,
 
Thanks for the tips!  At first I thought CEE APIs were off-limits to CL
programs, but I looked at the CEE API docs a little closer and remembered
CALLPRC in CLLE programs!
 
If anyone's interested, here's a quickie sample program I did to test that
it works.  Buyer beware - there's no error checking or message monitoring
(but there will be in my production app!)
 
- GA
 
Pgm
 
   Dcl     &YYMDstamp   *Char  (    17    )
   Dcl     &ErrorCode   *Char  (    32    )  Value( ' ' )
   Dcl     &YYMDtoday   *Char  (     8    )
   Dcl     &LilDateHex  *Char  (     4    )
   Dcl     &fc          *Char  (    12    )
   Dcl     &LilDateNbr  *Dec   (     8  0 )
   Dcl     &YYMDnxtWk   *Char  (     8    )
 
/* Using IBM API, get the current system timestamp             */
   Call       QWCCVTDT  Parm( '*CURRENT  '  ' '  '*YYMD     ' +
                                &YYMDstamp  &ErrorCode   )
 
   ChgVar     &YYMDtoday  Value( %sst( &YYMDstamp 1 8 ))
 
/* Convert today's date to lilian date, so we can do date math */
   CallPrc    CEEDAYS  Parm( &YYMDtoday  'YYYYMMDD'  &LilDateHex &fc)
 
/* Convert Lilian date hex value to numeric, add 7 days, +
    and convert back to hex value again.                       */
   ChgVar     &LilDateNbr  Value( %bin( &LilDateHex ))
   ChgVar     &LilDateNbr  Value( &LilDateNbr + 7 )
   ChgVar     %bin( &LilDateHex )  Value( &LilDateNbr )
 
/* Convert Lilian date back to a normal character date         */
   CallPrc    CEEDATE  Parm( &LilDateHex  'YYYYMMDD'  &YYMDnxtWk &fc)
 
TEST:   DmpCLpgm
 
Endpgm

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.