Categorize documents by the week number for every year

This column formula will group the entries into the correct number of weeks. Weeks start with Sunday and it also accounts for the overlap of days at New Year's.
Lotus Formula

Insert in your categorized column. In the example below, "OrderDate" is the date field in the documents.

datefldtocheck := OrderDate;

year := @Year(datefldtocheck);

firstdayofyear := @Date(year ; 1 ; 1 );
firstdayofyearweekday := @Weekday(firstdayofyear);

firstdayofweek2use := @If(
	firstdayofyearweekday = 1 ; firstdayofyear ;
	firstdayofyearweekday = 2 ; @Adjust(firstdayofyear; 0 ; 0 ; -1 ; 0 ;0 ;0) ;
	firstdayofyearweekday = 3 ; @Adjust(firstdayofyear; 0 ; 0 ; -2 ; 0 ;0 ;0) ;
	firstdayofyearweekday = 4 ; @Adjust(firstdayofyear; 0 ; 0 ; -3 ; 0 ;0 ;0) ;
	firstdayofyearweekday = 5 ; @Adjust(firstdayofyear; 0 ; 0 ; -4 ; 0 ;0 ;0) ;
	firstdayofyearweekday = 6 ; @Adjust(firstdayofyear; 0 ; 0 ; -5 ; 0 ;0 ;0) ;
	firstdayofyearweekday = 7 ; @Adjust(firstdayofyear; 0 ; 0 ; -6 ; 0 ;0 ;0) ;
	firstdayofyear
);

datediff:= datefldtocheck - firstdayofweek2use;

weeknumber := @Integer(datediff/604800) + 1;

@If(
	weeknumber = 53 ;
	@Text(year+1) + " - Week #01" ;
	@Text(year) + " - Week #" + @If(weeknumber<10 ; "0" + @Text(weeknumber) ; @Text(weeknumber))
)


Posted by fbrefere001 on Tuesday April 23, 2013