SOLVED

Weeknum Function

%3CLINGO-SUB%20id%3D%22lingo-sub-2203109%22%20slang%3D%22en-US%22%3EWeeknum%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203109%22%20slang%3D%22en-US%22%3E%3CP%3EWhile%20we%20using%20WEEKNUM%20Function%20the%20return%20type%20showing%20as%201%20and%2017%20where%20days%20begins%20on%20Sunday%20and%20I%20search%20there%20is%20no%20difference%20between%20both%20returns%20type%20same%20is%20happing%20with%202%20and%2011%20in%20case%20days%20begins%20on%20Monday.%3C%2FP%3E%3CP%3ESo%20is%20there%20any%20specific%20reason%20that%20given%20two%20return%20type%20for%20single%20day%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2203109%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2203125%22%20slang%3D%22de-DE%22%3ESubject%3A%20Weeknum%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203125%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F605939%22%20target%3D%22_blank%22%3E%40Prem_Kant_Pandey%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Fexcel.worksheetfunction.weeknum%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EReturn%20value%3C%2FA%3E%3C%2FP%3E%3CP%3EThe%20%3CSTRONG%3EWeekNum%3C%2FSTRONG%3E%20function%20considers%20the%20week%20containing%20January%201%20to%20be%20the%20first%20week%20of%20the%20year.%20However%2C%20there%20is%20a%20European%20standard%20that%20defines%20the%20first%20week%20as%20the%20one%20with%20the%20majority%20of%20days%20(four%20or%20more)%20falling%20in%20the%20new%20year.%20This%20means%20that%20for%20years%20in%20which%20there%20are%20three%20days%20or%20less%20in%20the%20first%20week%20of%20January%2C%20the%20%3CSTRONG%3EWeekNum%3C%2FSTRONG%3E%20function%20returns%20week%20numbers%20that%20are%20incorrect%20according%20to%20the%20European%20standard.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20following%20table%20represents%20possible%20values%20for%20%3CEM%3EArg2%3C%2FEM%3E.%3C%2FP%3E%3CDIV%20class%3D%22table-scroll-wrapper%22%3ERemarksReturn_type%20Week%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E1%3C%2FTD%3E%3CTD%3EWeek%20begins%20on%20Sunday.%20Weekdays%20are%20numbered%201%20through%207.%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2%3C%2FTD%3E%3CTD%3EWeek%20begins%20on%20Monday.%20Weekdays%20are%20numbered%201%20through%207.%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20be%20happy%20to%20know%20if%20I%20could%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E*%20Kindly%20Mark%20and%20Vote%20this%20reply%20if%20it%20helps%20please%2C%20as%20it%20will%20be%20beneficial%20to%20more%20community%20members%20reading%20here.%3C%2FP%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2203135%22%20slang%3D%22en-US%22%3EBetreff%3A%20Weeknum%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203135%22%20slang%3D%22en-US%22%3EIt's%20not%20that's%20I%20ask%2C%20I%20want%20to%20know%20why%201%20and%2017%20for%20Sunday%2C%20we%20can%20use%201%20only%20or%2017%20only%3C%2FLINGO-BODY%3E
Occasional Contributor

While we using WEEKNUM Function the return type showing as 1 and 17 where days begins on Sunday and I search there is no difference between both returns type same is happing with 2 and 11 in case days begins on Monday.

So is there any specific reason that given two return type for single day?

11 Replies

@Prem_Kant_Pandey 

Return value

The WeekNum function considers the week containing January 1 to be the first week of the year. However, there is a European standard that defines the first week as the one with the majority of days (four or more) falling in the new year. This means that for years in which there are three days or less in the first week of January, the WeekNum function returns week numbers that are incorrect according to the European standard.

 

The following table represents possible values for Arg2.

RemarksReturn_type Week begins
1Week begins on Sunday. Weekdays are numbered 1 through 7.
2Week begins on Monday. Weekdays are numbered 1 through 7.

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

 

* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.

It's not that's I ask, I want to know why 1 and 17 for Sunday, we can use 1 only or 17 only

@Prem_Kant_Pandey 

The WEEKNUM function can be used in two systems.

System 1 The function counts the start of the week on January 1st, ie January 1st of each year is the first week.

System 2 The week for function counting starts on the first Thursday of the year.

For example, let's say the 1 is not the first week because it is Wednesday.

However, 1/2020/1 is the first week as it is the first Thursday of year 2.

 

Return_type

Week begins with

System

1 ir omitted

Sunday

1

2

Monday

1

11

Monday

1

12

Tuesday

1

13

Wednesday

1

14

Thursday

1

15

Friday

1

16

Saturday

1

17

Sunday

1

21

Monday

2

 

Return value

The WEEKNUM function returns the week number (1-54).

 

Remarks

With a series date, Excel stores data internally and gives the number of days since January 1, 1900. For example, January 1, 1900 is serial number 1, January 1, 2020 is serial number 43831, because it was 43831 days after January 1, 1900.

 

error

If the serial_num argument is outside the range for the current date base value, an #NUM! Returned. For example, if the serial number (-3) is a negative value or a large number (100000000), an error value is returned.

 

If the return_type is outside the range given in the table above, the #NUM! Returned.

 

I hope I was able to answer your question.

 

Thank you for your understanding and patience

 

Nikolino

I know I don't know anything (Socrates)

It's not that's
If I want start day of week should be on sunday we can put the return type 1 that is bydefult, but why number 17 is listed in return type although it's return sunday as start day of a week

@Prem_Kant_Pandey 

WEEKDAY

One last tryhope I was understandable now. 

  • Return_type    Optional. A number that determines the type of return value.

Return_type                          Number returned

1 or omitted

Numbers 1 (Sunday) through 7 (Saturday). Behaves like previous versions of Microsoft Excel.

2

Numbers 1 (Monday) through 7 (Sunday).

3

Numbers 0 (Monday) through 6 (Sunday).

11

Numbers 1 (Monday) through 7 (Sunday).

12

Numbers 1 (Tuesday) through 7 (Monday).

13

Numbers 1 (Wednesday) through 7 (Tuesday).

14

Numbers 1 (Thursday) through 7 (Wednesday).

15

Numbers 1 (Friday) through 7 (Thursday).

16

Numbers 1 (Saturday) through 7 (Friday).

17

Numbers 1 (Sunday) through 7 (Saturday).

@Prem_Kant_Pandey 

That's historical reason. Numbers from 11 to 17 were introduced in Excel 2010 and they are not compatible with previous version of Excel. However, to keep compatibility from oldest versions to new ones, numbers before 10 which are used in previous versions, are also kept in the list.

 

These days very few people are on pre-Excel 2010 versions, however they are, thus both sets are kept.

@Sergei Baklan 

So as you saying that, there is no difference between return type 1 and 17 or 2 and 11 in WEEKNUM Function. am I right?

@Prem_Kant_Pandey 

I think you'll find the following description of the various returns for return_type is correct. I've tested it anyway:

 

return_type is:

A number that determines the type of return value:

1 = Default = 1st Sun on or after Jan 1 is D1 W1
2 = 1st Mon on or after Jan 1 is D1 W1
11 = 1st Mon on or after Jan 1 is D1 W1
12 = 1st Tue on or after Jan 1 is D1 W1
13 = 1st Wed on or after 1 Jan is D1 W1
14 = 1st Thu on or after 1 Jan is D1 W1
15 = 1st Fri on or after 1 Jan is D1 W1
16 = 1st Sat on or after 1 Jan is D1 W1
17 = 1st Sun on or after 1 Jan is D1 W1
21 = Mon of week with first Thu is D1 W1

 

All except return-type 21 start the week on the first return_type based day that falls on or after January 1st in the year of the serial number.

Option 21 is the ISO8601 system which provides for Day 1 of Week 1 to be the Monday of the first week that has a Thursday. Alternatively, and having the same effect, it is the Monday of the week in which Jan 4th falls.

Options 11 to 21 were introduced in Excel 2010.

 

Hope this helps more than it confuses.

 

best response confirmed by Prem_Kant_Pandey (Occasional Contributor)
Solution
You ask :
"So is there any specific reason that given two return type for single day?"
It's historic.
The answer is that WEEKNUM was part of the original Analysis ToolPak set of functions used by Microsoft in the first Windows version of Excel.
That function only had 2 return_types.
In Excel 2007 Analysis ToolPak functions became installed as 'normal' functions rather than requiring the installation of the Analysis ToolPak AddIn.
In Excel 2010, Excel added the return_types 11 to 17 plus return type 21.
You are correct that:
the algorithm for return_type 1 = same as return_type 17
the algorithm for return_type 2 = same as return_type 11
If look at the table I provided earlier you'll see on vertical scanning of 11 through to 17 the neat sequence: Mon, Tue, Wed, Thu, Fri, Sat, Sun
If Microsoft had decided that existing options 1 and 2 made options 11 and 17 otiose, then I think that users would have been more confused than by the duplication.
As usual, Microsoft could not have removed Options 1 and 2 because existing workbooks used those options.
Hope that helps more than it confuses.


Thanks Mr. Norman_Harker, your answer is very satisfied and logical, you have clear my doubt,

many many thanks to you.
That's OK. You've prompted me to think about updating the week numbering Callendar that Ron de Bruin (MVP) and I wrote many years ago and which is still a popular upload from his site. At present, we only have Options 1, 2, ISO, and simplistic (D1 W1 is 1st Jan).