Custom Week Number

AlmostBeginner19

New Member
Joined
Oct 30, 2019
Messages
11
If anyone could help on this, it would be greatly appreciated.
I thought this was gonna be just a simple WEEKNUM formula but it's giving me quite a hard time.

I have a column of dates (column A) and I want to get the week number based on a custom week.
The week starts from Thursday to Wednesday.
The year starts on January 2, 2020 so week 1 is from Jan 2 to Jan 8, 2020.
The last week of the year is Dec 31, 2020 to Jan 6, 2021, then the week number resets to 1.

I tried numerous other formulas but couldn't get it to work.
The last formula I tried is: =INT((A4-DATE(YEAR(A4+364)-1,1,2)-WEEKDAY(A4-1,12))/7)+2
Based on a formula I got from another forum. This is actually not the original formula, I tweaked it, trying to experiment in different ways, but still didn't work.

Thanks to anyone who would help.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try this:

Dante Amor
AB
1miércoles, 01 de enero de 202053
2jueves, 02 de enero de 20201
3viernes, 03 de enero de 20201
4sábado, 04 de enero de 20201
5domingo, 05 de enero de 20201
6lunes, 06 de enero de 20201
7martes, 07 de enero de 20201
8miércoles, 08 de enero de 20201
9jueves, 09 de enero de 20202
10viernes, 10 de enero de 20202
11sábado, 11 de enero de 20202
12domingo, 12 de enero de 20202
13lunes, 13 de enero de 20202
14martes, 14 de enero de 20202
15miércoles, 15 de enero de 20202
16jueves, 16 de enero de 20203
17viernes, 17 de enero de 20203
18sábado, 18 de enero de 20203
19domingo, 19 de enero de 20203
20lunes, 20 de enero de 20203
21martes, 21 de enero de 20203
22miércoles, 22 de enero de 20203
23jueves, 23 de enero de 20204
Hoja3
Cell Formulas
RangeFormula
B1:B23B1=INT((A1+4-DATE(YEAR(A1+365),-11,-1))/7)
 
Upvote 0
Got it. Thanks soooo much!
Though would it be possible to explain how you got this? Like why the +4, -11, and -1?
I just want to understand how this works so I could do it myself in the future.

Try this:

Dante Amor
AB
1miércoles, 01 de enero de 202053
2jueves, 02 de enero de 20201
3viernes, 03 de enero de 20201
4sábado, 04 de enero de 20201
5domingo, 05 de enero de 20201
6lunes, 06 de enero de 20201
7martes, 07 de enero de 20201
8miércoles, 08 de enero de 20201
9jueves, 09 de enero de 20202
10viernes, 10 de enero de 20202
11sábado, 11 de enero de 20202
12domingo, 12 de enero de 20202
13lunes, 13 de enero de 20202
14martes, 14 de enero de 20202
15miércoles, 15 de enero de 20202
16jueves, 16 de enero de 20203
17viernes, 17 de enero de 20203
18sábado, 18 de enero de 20203
19domingo, 19 de enero de 20203
20lunes, 20 de enero de 20203
21martes, 21 de enero de 20203
22miércoles, 22 de enero de 20203
23jueves, 23 de enero de 20204
Hoja3
Cell Formulas
RangeFormula
B1:B23B1=INT((A1+4-DATE(YEAR(A1+365),-11,-1))/7)
 
Upvote 0
The last week of the year is Dec 31, 2020 to Jan 6, 2021, then the week number resets to 1.

Sorry, I skipped that part. I checked the formula and now it is. It also calculates if the year will end with 52 or 53 weeks.

Formula for date in cell A4

=IF(INT((A4+CHOOSE(WEEKDAY(DATE(YEAR(A4),1,1),1),2,3,4,5,6,0,1)-DATE(YEAR(A4)-1,12,31))/7)=0,IF(WEEKDAY(DATE(YEAR(A4),1,1),1)=6,53,52),INT((A4+CHOOSE(WEEKDAY(DATE(YEAR(A4),1,1),1),2,3,4,5,6,0,1)-DATE(YEAR(A4)-1,12,31))/7))
 
Upvote 0
Thanks. It worked but I'm curious to know how the "1110111" part works. When you select a [weekend] it's only 1 to 17. :oops:


DanteAmor's formula doesn't seem to handle this condition correctly.

Here is my take on this:

=WEEKNUM(WORKDAY.INTL(A4+1,-1,"1110111"),21)
 
Upvote 0
This one worked as well. Thanks.

Sorry, I skipped that part. I checked the formula and now it is. It also calculates if the year will end with 52 or 53 weeks.

Formula for date in cell A4

=IF(INT((A4+CHOOSE(WEEKDAY(DATE(YEAR(A4),1,1),1),2,3,4,5,6,0,1)-DATE(YEAR(A4)-1,12,31))/7)=0,IF(WEEKDAY(DATE(YEAR(A4),1,1),1)=6,53,52),INT((A4+CHOOSE(WEEKDAY(DATE(YEAR(A4),1,1),1),2,3,4,5,6,0,1)-DATE(YEAR(A4)-1,12,31))/7))
 
Upvote 0
@ AlmostBeginner19:

Glad it worked for you.

The "1110111" declares Thursday as the only workday; all other days (Mon, Tue, Wed, Fri, Sat, Sun) are declared as holidays: "1110111".

The WORKDAY.INTL(A4+1,-1,"1110111") returns the date of the previous Thursday for Mon, Tue, Wed, Fri, Sat, Sun.
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,973
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top