简体   繁体   English

计算Excel中一年的周数

[英]Calculating the week number of a year in Excel

I'm trying to calculate the week number of a week in a year in excel using the formula =WEEKNUM(A1,2) .我正在尝试使用公式=WEEKNUM(A1,2)计算 excel 中一年中一周的周数。

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.由于日期 1、2、3 是去年的最后一周。

How do I get the above result我如何获得上述结果

Based on @ScottCraner comment, I was able to get the result.根据@ScottCraner 的评论,我能够得到结果。 Here is my excel formula.这是我的 excel 公式。

=IF(AND(A1>=DATE(YEAR(A1),1,1),A1<DATE(YEAR(A1),1,8)-WEEKDAY(DATE(YEAR(A1),1,6))),53,WEEKNUM(A1,2))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM