Hi again
An example for calculating a weeknumber in format 'yyyy.ww' (I prefer this
format, because it enables sorting when there are data from severel years in
table) from date in A2 (I didn't edit delimiters in formulas, as there is
too much of them, and it'll be confusing when I miss one)
=(YEAR(A2)+AND(DayNum<4;WeekNum>50)*(-1)+AND(DayNum>262;WeekNum=1)*1) & "."
& TEXT(WeekNum;"00")
,where DayNum, WeekNum, Week1 and Week2 are named ranges, defined with cell,
you are the formula writing to, activated.
DayNum=DATEDIF(DATE(YEAR(A2);1;0);A2;"D")
Week1=INT(((DATE(YEAR(A2)-1;12;31) -
DATE(YEAR(A2)-1;1;1)+1)+7-WEEKDAY(DATE(YEAR(A2)-1;12;31);2)+4)/7)
Week2=IF(AND(INT((DayNum+7-WEEKDAY(A2;2)+4)/7)=53;WEEKDAY(DATE(YEAR(A2);12;3
1);2)<4);1;INT((DayNum+7-WEEKDAY(A2;2)+4)/7))
WeekNum=IF(INT((DayNum+7-WEEKDAY(A2;2)+4)/7)=0;Week1;Week2)
The formula above returns a string value. You can convert it into number,
enclosing it into VALUE function.
As I sayd before, the same date can belong to different week in different
countries (there are several ISO's). Probably you have to modify formulas
above.
There is a function for calculating a weeknumber in Excel2000, but there you
can determine the the starting day for week, but not how is determined the
first week of year (p.e. for me, the date 29. December 2003 belongs to week
2004.01, and date 02. January 2005 belongs to week 2004.53, but weeknum
returns 53 for first date and 1 for second one. And worse - p.e. for date
01. January 2004, which belongs to same week as 29. December 2003, it
returns 1!!!)