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


  • Subject: RE: Calculating Working(business) days
  • From: "Stone, Brad V (TC)" <bvstone@xxxxxxxxxxxxxx>
  • Date: Thu, 24 Aug 2000 08:39:17 -0500

We just had to do this.  We did it using a set of date subprocedures that we
have...  went something like this (nasty psudeocode)...

Date1 = Start Date
Date2 = End Date
NumWorkDays = 0

dow (Date2 > Date1)
  Day = #NameofDay(#DayofWeek(Date2))
  if (Day <> 'Saturday') and (Day <> 'Sunday')
    NumWorkDays = (NumWorkDays + 1)
  endif
  Date2 = (Date2 - 1 day)
enddo 

The only realy thing we had to write was #DayofWeek() which when passed a
date data type returns a number representing the day (ie 1=Sunday, 2=
Monday, etc..)  Then we wrote #NameofDay which when passed a number (1-7)
returns the name of the day.

I originally wrote these for e-RPG since dates have to be in a funky format
for headers, cookies, etc. (like Mon, 10 Dec 2000)  They ended up working
for this as well.

Now, what we really should do is write another subprocedure that when passed
two dates retrieves the number of working days...  That will be the next
addition to our F.DATE service program.  :)  ILE rules!!!

Brad

> -----Original Message-----
> From: Jeff Crosby [mailto:jlcrosby@fwi.com]
> Sent: Thursday, August 24, 2000 8:12 AM
> To: RPG400-L@midrange.com
> Subject: Re: Calculating Working(business) days
> 
> 
> Alan Addison wrote:
> 
> > Take the duration, divide it by five and multiply it by 
> seven, then add
> > that number of days to the starting date.
> 
> Actually, It's not that simple.  The calculated date could 
> end up being
> a Sat or Sun.  Then you have to adjust it.
> 
> -- 
> -Jeff
> The opinions expressed are my own and not necessarily 
> the opinion of my company.  Unless I say so.
> +---
> | 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-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.