Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Work day count between two dates
Message
From
15/08/2002 00:59:36
 
 
To
14/08/2002 22:55:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00689838
Message ID:
00689852
Views:
21
>Hi all,
>
>I'm coding some project metrics using input from a MS Project ASCII export. Cosidering scheduling typically uses only work days (M-F), I need some help coding a routine which will count the number of work days (exlcuding Sat and Sun) between two dates. any assistance would be appreciated...

You could brute-force it with something like this:
FUNCTION WorkDays
LPARAMETERS tdStart, tdEnd
LOCAL lnWorkDays, ldTest

lnWorkDays = 0
ldTest = tdStart

DO WHILE ldTest <= tdEnd
  IF DOW(ldTest) > 1 AND DOW(ldTest) < 7
    lnWorkDays = lnWorkDays + 1

  ENDIF

  * Increment test date by 1 day:
  ldTest = ldTest + 1

ENDDO

RETURN lnWorkDays
This routine could be improved to handle stat holidays by creating a small table of the holiday dates indexed on the date of the holiday. Do an IF SEEK() on this table inside the IF DOW() condition and if the result is .F. then the test date is not a stat.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform