I'm trying to calculate the week number of a week in a year in excel using the formula =WEEKNUM(A1,2)
.
My Result:
----------------------
| Date | Week |
|2021-01-01| 1 |
|2021-01-02| 1 |
|2021-01-03| 1 |
|2021-01-04| 1 |
|2021-01-05| 1 |
|2021-01-06| 1 |
|2021-01-07| 1 |
----------------------
Result which I want:
----------------------
| Date | Week |
|2021-01-01| 53 |
|2021-01-02| 53 |
|2021-01-03| 53 |
|2021-01-04| 1 |
|2021-01-05| 1 |
|2021-01-06| 1 |
|2021-01-07| 1 |
----------------------
Since Date 1,2,3 are in the last week of the last year.
How do I get the above result
Based on @ScottCraner comment, I was able to get the result. Here is my excel formula.
=IF(AND(A1>=DATE(YEAR(A1),1,1),A1<DATE(YEAR(A1),1,8)-WEEKDAY(DATE(YEAR(A1),1,6))),53,WEEKNUM(A1,2))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.