The Date Field Extractor node tells me that 29.Dec.2014 is in the 1st week of 2014, whereas it should belong to 2015 from a week perspecctive. Similar thing happens to the last days of earlier years.
There may be a bug here. The week information seem to be extracted from somewhere, then overwritten by the year the specific day is in.
My current workaround is to add 1 to year if the week is 1.
Is this really a bug or am I doing something wrong here? (My regional settings are set to English (Untied States))
Year and WeekOfYear are two completely independent values in this case. Both are correctly determined in your example: the year is certainly 2014 and the week is (due to the samewhat strange calendar definition) the first week (of 2015).
Then what how can I get Dec 29th 2014 as the 1st week of 2015?
You could use the Rule Engine node with a rules similar to
($Week$ = 1) AND ($Month$ = 12) => $Year$ + 1
TRUE => $Year$
I forgot to mention that I also have another table with daily values and in that table I have Jan 1st 2015 showing up as the 1st week of 2015. I'm trying to make both Jan 1st 2015 and Dec 29th 2014 belong to the same week.
This is exactly what the two rules I mentioned will achieve.
I am also trying to calculate a correct week number for a given date.
This works pretty fine except for the dates between 28.12.2015 to 03.01.2016.
The correct week number should be 53, but the node 'Time to String' returns week number 1.
In combination with the node 'Rule Engine' I get for exampe CW 1-2016 for the date 29.12.2015, which should be CW 53-2015.
How can this be fixed?
Also is it possible to calculate the financial/fiscal week number for a given date?
Should the correct week number be 53 for ISO, US or both? Just checking, because I dimly recall that for 2015, numbering was "US == ISO", whereas in 2016 it was "US != ISO". That notwithstanding, it may well be a bug you have found. :-)
P.S.: Happy 2016, all!!!
The first day of the week is locale specific. With US locale it's the first week contains January 1st therefore the current week is the first of 2016. In many other locales (and in ISO) the first week is the one containing January 4th.
So no bug, presumably? :)
No, this works as expected.
I have been trying to continue generating weekly reports this year, but my week numbers have been off. The first week of this year should be the week of January 3rd, not December 27th. Now I know why.
I do not believe that the standard US week numbering system defines the first week of the year as whichever week contains January 1st.
The US week numbering system does start weeks on Sundays (which KNIME correctly handles); however, the most commonly used US week numbering systems [that I have seen] involve either setting the first week of the year as the first full week of January or the first week of the year with 4 or more January days.
So I would argue that, while this is expected behavior and not a bug from a KNIME developer standpoint, it is not expected behavior from a US user standpoint. Perhaps there could be options in the Date Field Extractor node for setting the first week of the year to be either:
- The week containing January 1st
- The first full week of January
- The first week of the year with 4 or more January days
Until then, I will have to abandon my use of the week number in my reports.