Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating work days
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00338999
Message ID:
00339085
Views:
20
>I can't resist this.< g > Here's my approach, but it's old. It was originally designed for a FPW 2.6 system that is now defunct (that should explain the format for everyone).
* FUNCTION: Bus_Days.prg
>* AUTHOR: George Tasker
>* DATE: July 30, 1996 - 4:53 PM
>* PURPOSE: Returns the number of business days
>* between two dates
>
>PARAMETERS p_start, p_stop
>
>PRIVATE m.days, m.stop, m.num_weeks
>m.days = (p_stop - p_start) + 1
>m.num_weeks = INT(m.days / 7)
>m.result = m.num_weeks * 5
>m.add_days = m.days % 7
>m.stop = p_stop - m.add_days
>DO WHILE m.stop < p_stop
>  m.stop = m.stop + 1
>  IF NOT INLIST(DOW(m.stop), 1, 7)
>    m.result = m.result + 1
>  ENDIF
>ENDDO
>RETURN m.result
Marcia, however, does have a good idea about the Holidays table. To incorporate that into the above, I'd simply use a COUNT TO m.holdays FOR BETWEEN(holi_date, p_start, p_stop) (where holi_date is the name of the date field holding the holiday date) and subtract the value in m.holidays.

Thanks George,

This is exactly what I'm looking for. I definitely got to get down to Georgia and pay up my Dark Beer tab! I was very close to debugging my version but yours is cleaner, less code and should execute faster. I may elect to remove holidays as well but is not critical - Thanks Marcia.
Michael McLain
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform