Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Found Week Number from given date
Message
From
27/07/2021 18:03:20
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Found Week Number from given date
Miscellaneous
Thread ID:
01681946
Message ID:
01681946
Views:
57
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
Next
Reply
Map
View

Click here to load this message in the networking platform