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



It seems to me that you have to use a calender because there are also
holidays to consider in this equation.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Rowe, Sheri
Sent: Wednesday, January 10, 2007 2:48 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: finding a date

Hi,

 

I need to change some code to get a date, based on today plus 'x'
working days (Mon to Fri).  I originally wrote code to have today plus
'x' days which works,  but now we need to exclude weekends (Sat & Sun)
when we are counting the days, and I am not sure how to accomplish this.

 

e.g.  today is  Wednesday January 10th  + 22 work days would be Friday
February 9th.

 

Here is my code:

D #SPSDT_D        S               D   DatFmt(*ISO)  

D #SPSDT_S        S              8S 0               

C*                     

C* Calculate the period end date of the week                         

C                   EVAL      #SPSDT_S = #SPECC * 1000000 + #SPEDT   

C*                                                                   

C* Convert from numeric to date format                               

C                   EVAL      #SPSDT_D    = %DATE(#SPSDT_S)          

C*                                                                   

C* Add or Subtract the date                                          

C                   IF        @OpCode = '-'                          

C                   EVAL      #Dur = #Dur * -1                       

C                   ENDIF                                            

C*                                                                   

C* Calculate the period start date of the week                       

C                   ADDDUR    #Dur:*days    #SPSDT_D                 

C* Extract data for calculation purpose                              

C                   EXTRCT    #SPSDT_D:*Y   #SPSCY            4 0    

C                   EXTRCT    #SPSDT_D:*M   #SPSMM            2 0    

C                   EXTRCT    #SPSDT_D:*D   #SPSDD            2 0    

C*                                                                   

C* Convert to numeric format from date format                        

C                   EVAL      #SPSDT = #SPSCY*10000+#SPSMM*100+#SPSDD

C*                                                                   

C* End Program                                                       

C                   MOVE      '1'           *InLR                    

C*                                                                   

C*****************************************************************   

C*  Initialization Subroutine                                        

C*****************************************************************   

C*                                                                   

C     *INZSR        BEGSR                                            

C* Program entry point                                               

C     *ENTRY        PLIST                                            

C                   PARM                    @SPECC            2      

C                   PARM                    @SPEDT            6      

C                   PARM                    @Dur              3      

C                   PARM                    @OpCode           1      

C                   PARM                    #SPSDT            8 0    

C*                                                                   

C                   MOVE      @SPECC        #SPECC            2 0    

C                   MOVE      @SPEDT        #SPEDT            6 0    

C                   MOVE      @Dur          #Dur              3 0    

C*                                                                   

C                   ENDSR                                            

 

Thanks for any assistance.

                             

 

Sheri Rowe

Timex Canada

445 Hood Road,

Markham, On L3R 8H1

 

 



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.