Hi Luis,
the week number may be different from country to country, since the definition may vary. In Norway December 31st 2019 belongs to week no. 1 in 2020. If you wonder why, I suggest that you ask Google.
I see no reason to NOT use Week() since it should always give the right answer. The second parameter lets you select the correct rule in your country.
>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
Hi Tore,
Thanks for your reply, i will go to search more information on google.
Best regards,
Luis