hi alberto,
I share the algo we use from years.
manu
SUBROUTINE WeekNo(WEEK, DATE)
year = OCONV(DATE, 'D4Y')
gosub calc
WEEK = int((DATE - day1) / 7) + 1
if DATE < day1 then
year -= 1
gosub calc
WEEK = int((DATE - day1) / 7) + 1
end else
if WEEK = 53 then
year += 1
gosub calc
if day1 >= dd0101 then WEEK = 1
end
end
return
*---------------------------------------
calc:
date0101 = ICONV('01.01.' : year, 'D4.') ;* date of first january
dd0101 = OCONV(date0101, 'DW') ;* day of week of first january
if dd0101 < 4 then shift = 1 else shift = 8
day1 = date0101 - dd0101 + shift
return