Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Work day count between two dates
Message
De
15/08/2002 00:59:36
 
 
À
14/08/2002 22:55:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00689838
Message ID:
00689852
Vues:
22
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform