Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Work days between two dates - finally!
Message
De
08/06/2003 10:11:04
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00797684
Message ID:
00797752
Vues:
29
I think that an efficient technique for accounting for holidays would be something like this.
create table holidays (;
  dDate d, ;
  nDow  n(1), ;
  lWorkDay L, ;
  cDesc c(40) )

Index on dDate tag dDate
index on ndow tag nDow
index on lworkday tag lWorkday
Then you could "count" holidays between to dates like this:
function holidays
lparameter ddate1, ddate2
local laHoliday(1)
store 0 to laHoliday

select count(*) as nHolidays from holidays ;
  into array laHoliday
  where ddate between ddate1 and ddate2 and ;
    lworkday = .t.

return laHoliday(1)
>>Hi Nadya
>>
>>I intend no offence, but IMO checking for holidays should be a separate function. That way one could always check what holidays are coming up in the next month. This separate function can be called from the workdays routine by passing in the same date parameters.
>
>Agree, it could be and better be a separate function. It would return number of holiday days and we would just need to substract them.
>
>The problem with holidays, that they are not consistant, so for each year we would need a table of Holidays.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform