Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Odd behavior in Week function

I've been playing with the Week function (only because a user requested it) and noticed something quite strange. I'm just wondering if anybody else has noticed that when the last days of December fall on Monday thru Wednesday, the evaluation of Week is returning 1. I loaded a calendar with values staring in 1956, and it shows up repeatedly:

LinkDateMonthQuarterYearWeek
12/31/1956DecQ419561
12/30/1957DecQ419571
12/31/1957DecQ419571
12/29/1958DecQ419581
12/30/1958DecQ419581
12/31/1958DecQ419581
12/31/1962DecQ419621
12/30/1963DecQ419631
12/31/1963DecQ419631
12/30/1968DecQ419681
12/31/1968DecQ419681
12/29/1969DecQ419691
12/30/1969DecQ419691
12/31/1969DecQ419691
12/31/1973DecQ419731
12/30/1974DecQ419741
12/31/1974DecQ419741
12/29/1975DecQ419751
12/30/1975DecQ419751
12/31/1975DecQ419751
12/31/1979DecQ419791
12/29/1980DecQ419801
12/30/1980DecQ419801
12/31/1980DecQ419801
12/31/1984DecQ419841
12/30/1985DecQ419851
12/31/1985DecQ419851
12/29/1986DecQ419861
12/30/1986DecQ419861
12/31/1986DecQ419861
12/31/1990DecQ419901
12/30/1991DecQ419911
12/31/1991DecQ419911
12/30/1996DecQ419961
12/31/1996DecQ419961
12/29/1997DecQ419971
12/30/1997DecQ419971
12/31/1997DecQ419971
12/31/2001DecQ420011
12/30/2002DecQ420021
12/31/2002DecQ420021
12/29/2003DecQ420031
12/30/2003DecQ420031
12/31/2003DecQ420031
12/31/2007DecQ420071
12/29/2008DecQ420081
12/30/2008DecQ420081
12/31/2008DecQ420081
12/31/2012DecQ420121
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Week 1 is the first week with 4 or more days in the new year. This is an international convention (if maybe even a standard). Consequently, the weeks with 4, 5 or 6 days in the new week will have days in the old year. That's what you're seeing.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Week 1 is the first week with 4 or more days in the new year. This is an international convention (if maybe even a standard). Consequently, the weeks with 4, 5 or 6 days in the new week will have days in the old year. That's what you're seeing.


talk is cheap, supply exceeds demand
Not applicable
Author

You're quite right about it being a standard. After reading your reply, I did a little digging and found that ISO-8601 states that the first week of the year is the one that contains the first Thursday. This is the definitive rule set:

Dates in JanuaryEffect
MTWTFSSWeek numberWeek assigned to
12345671New year
1234561New year
123451New year
12341New year
12352 or 53Previous year
1252 or 53Previous year
152 or 53Previous year