Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Found Week Number from given date
Message
De
27/07/2021 18:03:20
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Found Week Number from given date
Divers
Thread ID:
01681946
Message ID:
01681946
Vues:
58
Hello comunity,

I found this function for returning Week number from given Date, but failed on certain year !?
?getweekno(DATE(2019,12,31))
Return = 1

FUNCTION GetWeekNo
 LPARAMETERS ldDate
 lnJulian = VAL(SYS(11,ldDate))+1
 lnDay4 = MOD(MOD(MOD((lnJulian+31741 - MOD(lnJulian,7)),146097),36524),1461)
 lnLeap = INT(lnDay4/1460)
 lnDay1 = MOD(lnDay4-lnLeap,365) + lnLeap
 RETURN INT(lnDay1/7)+1
ENDFUNC
the same work great for 31.12.2021, 31.12.2020, but for 31.12.2019 they return : 1
also, i use :
?WEEK(DATE(2019,12,31),2,2)
Result = 1
Why ?

Many Thanks,
Best regards,
Luis
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform