Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Interesting Week() Behaviour

I'm seeing some strange results when using the Week() function when FirstWeekDay=0. When FirstWeekDay=6, things appear normal, but changing it to 0 produces something I don't understand.

E.g. if I use this as an expression (when FirstWeekDay=0):

Week(Date#('12/31/2016', 'M/D/YYYY'))

& '|' &

Week(Date#('1/1/2017', 'M/D/YYYY'))

& '|' &

Week(Date#('1/2/2017', 'M/D/YYYY'))

The result is:

53 | 1 | 2

I understand that there were 53 ISO weeks last year, but how could Jan. 1st of this year be week 1, and Jan. 2 be week 2? Shouldn't Jan 1st still be in week 53 and Jan 2nd be in week 1?

1 Solution

Accepted Solutions
annapochyla
Partner - Contributor III
Partner - Contributor III

There is one more system variable you should take into consideration:

SET BrokenWeeks=0;

Default value is 0, but if you will change it to 1, then you will get this unexpected result.

1 means that for each year you start the weeks numeration from the beginning.

View solution in original post

3 Replies
sunny_talwar

Not sure I understand the behavior, but WeekName gives this...

Capture.PNG

=WeekName(Date#('12/31/2016', 'M/D/YYYY'))

& ' | ' &

WeekName(Date#('1/1/2017', 'M/D/YYYY'))

& ' | ' &

WeekName(Date#('1/2/2017', 'M/D/YYYY'))

annapochyla
Partner - Contributor III
Partner - Contributor III

There is one more system variable you should take into consideration:

SET BrokenWeeks=0;

Default value is 0, but if you will change it to 1, then you will get this unexpected result.

1 means that for each year you start the weeks numeration from the beginning.

Anonymous
Not applicable
Author

Thanks Anna, that corrects my issue. My default BrokenWeeks is one for some reason, but changing to 0 gives the results I was expecting.