Thanks Petra,
that piece of code does work well during the year, but at the end of the year you'll get shorter periods (as there are sometimes weeks with only 1 day, i.e. Mon 18-12-31 is only one day in week 53, so on Wed 19-01-02 you'll increase Weeknum too early). And you'll get longer periods if you are in the right week, but if the stock markets were closed that TUESDAY.