Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date() + 3
Message
De
21/07/2005 23:25:56
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
21/07/2005 22:58:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01034976
Message ID:
01034980
Vues:
15
>Hi all,
>
>How to avoid Saturday and Sunday when used date() + 3 ?
>
>If it falls on both Saturday and Sunday that date() + 3 should skip next
>Monday .
>
>date() is Monday , date()+3 is Thursday OK
>date() is Tuesday, date()+3 is Friday OK
>date() is Wednesday, date()+3 is Saturday not OK
>date() is Wednesday, Date() + 3 + ??? shoul be next monday OK
>how to do this, please assist me in coding ?

And what day is 3 days from Friday - Monday, or do you want to count 3 working days up to Tuesday? I will assume the latter. It would be something like this:
function AddWorkingDays(tdDate, tnDays)
local i, tdResult
tdResult = tdDate
for i = 1 to tnDays
  tdResult = tdResult + 1
  if dow(tdResult) = 7 && Saturday
  	tdResult = tdResult + 1
  endif
  if dow(tdResult) = 1 && Sunday
  	tdResult = tdResult + 1
  endif
next
return tdREsult
If you want to add hundreds or thousands of days, some optimizations would be convenient, for example, start dividing by seven (integer division) to see how many entire weeks you got - and multiply the number of weeks by 5 (5 working days a week).
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform