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



Rick,

There is a TAATOOL called ADDDAT that will allow you to add number of days to a 
date.  This is great command for doing what you are wanting.

In the absence of this command, the following is some CL code that will allow 
you to add dates.  The code is provided "as-is".  You will need to ensure that 
it is appropriate for your environment.

With this program, you would pass the beginning date and the number of days you 
want to add (the number can be a negative).  The program will return the end 
date.


PGM           PARM(&begdate                           +
                   &days                              +
                   &enddate  )

   DCL        VAR(&begdate   )                        + 
              TYPE(*CHAR     )                        + 
              LEN(6          )                          
   DCL        VAR(&day       )                        + 
              TYPE(*CHAR     )                        + 
              LEN(2          )                          
   DCL        VAR(&days      )                        + 
              TYPE(*CHAR     )                        + 
              LEN(3          )                          
   DCL        VAR(&daywrk    )                        + 
              TYPE(*DEC      )                        + 
              LEN(5 0        )                          
   DCL        VAR(&dow       )                        + 
              TYPE(*DEC      )                        + 
              LEN(1 0        )                          
   DCL        VAR(&dpy       )                        + 
              TYPE(*DEC      )                        + 
              LEN(3 0        )                          
   DCL        VAR(&enddate   )                        + 
              TYPE(*CHAR     )                        + 
              LEN(6          )                          
   DCL        VAR(&fday      )                        + 
              TYPE(*CHAR     )                        + 
              LEN(1          )                          
   DCL        VAR(&jdays     )                        + 
              TYPE(*DEC      )                        + 
              LEN(5 0        )                          
   DCL        VAR(&jdaysc    )                        + 
              TYPE(*CHAR     )                        + 
              LEN(3          )                          
   DCL        VAR(&jul       )                        + 
              TYPE(*CHAR     )                        + 
              LEN(5          )                          
   DCL        VAR(&jyer      )                        + 
              TYPE(*DEC      )                        + 
              LEN(3 0        )                          
   DCL        VAR(&jyerc     )                        +
              TYPE(*CHAR     )                        +
              LEN(3          )                         
   DCL        VAR(&ldiv      )                        +
              TYPE(*DEC      )                        +
              LEN(3 0        )                         
   DCL        VAR(&rundate   )                        +
              TYPE(*CHAR     )                        +
              LEN(8          )                         
   DCL        VAR(&today     )                        + 
              TYPE(*CHAR     )                        + 
              LEN(9          )                          
   DCL        VAR(&work      )                        +
              TYPE(*DEC      )                        +
              LEN(6 0        )                         
   DCL        VAR(&work2     )                        +
              TYPE(*DEC      )                        +
              LEN(6 0        )                         
   DCL        VAR(&work3     )                        +
              TYPE(*DEC      )                        +
              LEN(9 3        )                         
   DCL        VAR(&year      )                        + 
              TYPE(*CHAR     )                        + 
              LEN(2          )                          
   DCL        VAR(&yr        )                        + 
              TYPE(*DEC      )                        + 
              LEN(3 0        )                          



   CHGVAR     VAR(&daywrk    )                        + 
              VALUE(&days    )                          
                                                         
   CVTDAT     DATE(&begdate  )                        + 
              TOVAR(&jul     )                        + 
              FROMFMT(*MDY   )                        + 
              TOFMT(*JUL     )                        + 
              TOSEP(*NONE    )                          
                                                        
   CHGVAR     VAR(&jyer      )                        +
              VALUE(%sst(&jul 1 2))                    
   CHGVAR     VAR(&jdays     )                        +
              VALUE(%sst(&jul 3 3))                    
                                                        
   IF         COND(&jyer *eq 0)                       + 
              THEN(CHGVAR                             + 
              VAR(&jyer      )                        + 
              VALUE(&jyer + 100))                       
                                                       
leapchk:                                               
                                                       
   CHGVAR     VAR(&ldiv      )                        +
              VALUE(&jyer / 4)                         
   CHGVAR     VAR(&dpy       )                        +
              VALUE(      365)                         
                                                       
   IF         COND((&ldiv * 4) *eq &jyer)             +
              THEN(CHGVAR                             +
              VAR(&dpy       )                        +
              VALUE(     366))                         
                                                       
   IF         COND(&daywrk *gt &dpy)                  +
              THEN(DO        )                         
                                                       
      CHGVAR     VAR(&daywrk    )                     +
                 VALUE(&daywrk - &dpy)                  
      CHGVAR     VAR(&jyer      )                     + 
                 VALUE(&jyer + 1)                       
      GOTO       CMDLBL(leapchk )                       
                                                        
   ENDDO                                                
                                                        
   CHGVAR     VAR(&jdays     )                        + 
              VALUE(&jdays + &daywrk)                   
                                                        
daycalc:                                                
                                                        
   IF         COND(&jdays *gt &dpy)                   + 
              THEN(DO        )                          
                                                        
      CHGVAR     VAR(&jdays     )                     + 
                 VALUE(&jdays - &dpy)                   
      CHGVAR     VAR(&jyer      )                     + 
                 VALUE(&jyer + 1)                       
      CHGVAR     VAR(&ldiv      )                     + 
                 VALUE(&jyer / 4)                       
      CHGVAR     VAR(&dpy       )                     + 
                 VALUE(365      )                       
      IF         COND((&ldiv * 4) *eq &jyer)          + 
                 THEN(CHGVAR                          + 
                 VAR(&dpy       )                     + 
                 VALUE(366     ))                       
      GOTO       CMDLBL(daycalc )                       
                                                        
   ENDDO                                                
                                                        
daycaln:                                                

   IF         COND(&jdays *le  0)                     + 
              THEN(DO        )                          
                                                        
      CHGVAR     VAR(&jyer      )                     + 
                 VALUE(&jyer - 1)                       
      CHGVAR     VAR(&ldiv      )                     + 
                 VALUE(&jyer / 4)                       
      CHGVAR     VAR(&dpy       )                     + 
                 VALUE(365      )                       
                                                        
      IF         COND((&ldiv * 4) *eq &jyer)          + 
                 THEN(CHGVAR                          + 
                 VAR(&dpy       )                     + 
                 VALUE(366     ))                       
                                                        
      CHGVAR     VAR(&jdays     )                     + 
                 VALUE(&jdays + &dpy)                   
                                                        
      GOTO       CMDLBL(daycaln )                       
                                                        
   ENDDO                                                
                                                        
   IF         COND(&jyer *ge 100)                     + 
              THEN(CHGVAR                             + 
              VAR(&jyer      )                        + 
              VALUE(&jyer - 100))                       
                                                       
   CHGVAR     VAR(&jyerc     )                        +
              VALUE(&jyer    )                         
   CHGVAR     VAR(&jdaysc    )                        +
              VALUE(&jdays   )                         
   CHGVAR     VAR(&jul       )                        +
              VALUE(%sst(&jyerc 2 2) *cat &jdaysc)     
                                                       
   CVTDAT     DATE(&jul      )                        +
              TOVAR(&enddate )                        + 
              FROMFMT(*JUL   )                        + 
              TOFMT(*MDY     )                        + 
              TOSEP(*NONE    )                          
                                                        
ENDPGM


Hope this helps.


Todd Kidwell (Netstar)
AS/400 System Administrator

>>> <rbrightman@amclog.com> 01/07/00 10:15AM >>>


Is there a simpler way of adding a certain number of days to a date  to get a
new date (in CL only)? I know I can call a home made RPG progam, But can it be
done in CL only?

Rick


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com 
+---
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.