Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Last day of the week
Message
De
28/07/2004 16:47:32
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
28/07/2004 16:18:57
Sony Joseph
Dovenmuehle Mortgage Inc
Schaumburg, Illinois, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00928869
Message ID:
00928905
Vues:
26
>Hi,
>
>Sorry. As I guessed, there is no short functions. So I had to write this.
>
>Function LastDowbyWeekNo(tnWeek, tnYear)
> *-- Purpose : Get the last day of the week by a week number
> Local ldTempDate
>
> If Parameters() < 2
> tnYear = Year(Date())
> Endif
>
> tnOffSet = tnWeek-2
> ldTempDate = Date(tnYear,1,1)
>
> Do While Week(ldTempDate) < tnWeek
> ldTempDate = ldTempDate+1
> Enddo
> Do While Week(ldTempDate)=tnWeek
> ldTempDate = ldTempDate+1
> Enddo
> Return ldTempDate-1

You might combine the two DO WHILE loops into one:
do while week(ldTempDate) <= tnWeek
  ldTempDate = ldTempDate + 1
enddo
Or, better yet, for better performance try to approach the desired date before you run the main loop. For instance, adding date(lnYear, 1, 1) + 7 * (tnWeek-2) should get you fairly close.
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
Répondre
Fil
Voir

Click here to load this message in the networking platform