P002143_k
P002143_k

Reputation: 39

Excel how to convert weeknum to date when crossing the year

I have a table with Date column and weeknum column.

enter image description here

The weeknum column has below formula to create a srting: 2022/10. =YEAR([@[Date]})&"/"&WEEKNUM([@[Date]],2)

I would like to get the start day and end day of the week converting from the string "2022/10".

I tried =DATE($M$1,1,-2)-(WEEKDAY(DATE($M$1,1,3))+(MID(M4,6,2)*7)) where $M$1 references current year and M4 references Year/ weeknum but it returns 10/17/2021. It should return 2/28/2022, and as the weeknumber increases. the returned dates decrease. The dates of 2021/53 are correct, but the others got wrong.

enter image description here

How do I get fixed the dates?

Upvotes: 1

Views: 1441

Answers (1)

NelliNoodle
NelliNoodle

Reputation: 158

You can do this by taking the weekday number of the date away from itself and adding 7-weekday to itself.

i.e.

If we use the first date on your list and we say weeks start on Monday:

The first day of the week (Monday) = E2-WEEKDAY(E2,2)+1 = 12/27/21

The last day of the week (Sunday) = E2+(7-WEEKDAY(E2,2)) = 01/02/22

Note: I have assumed your first date (12/27/2021) is in Cell E2

If you want Sunday to be the first day of the week, simply add a 1 instead of a 2 into the WEEKDAY part of the formula.

Upvotes: 1

Related Questions