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



Sheri,

I would calculate how many full weeks in your 22 working days (22 div 5 = 4) 
then add 4 times 2 to the duration. To keep it simple. You could get really 
complex if you want and take into consideration what day you are starting on 
and figure exactly how many weekends are involved.

But then again you are not taking into consideration stat holidays either. You 
could build a working day calander to specify working/non-working days for the 
year(s).

May I also recommend that you take full advantage of RPGLEs date %BIFs. It 
could cut your code down by at least 50% when dealing with date calculations. 
It's wonderful over the old way.
 
Good Luck
Bill
Chatham, Ontario, Canada
(All else fails READ THE INSTRUCTIONS)



----- Original Message ----
From: "Rowe, Sheri" <srowe@xxxxxxxxx>
To: rpg400-l@xxxxxxxxxxxx
Sent: Wednesday, January 10, 2007 2:47:55 PM
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 ...

Follow-Ups:

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.