[英]Calculate the start date and end date of week number
I'm using the following formulas to obtain the start date and end date of the week number, given the week number and the year: 给定星期数和年份,我使用以下公式获取星期数的开始日期和结束日期:
Start of week: =MAX(DATE(A2,1,1),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+(B2-1)*7+1)
周开始: =MAX(DATE(A2,1,1),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+(B2-1)*7+1)
End of week: =MIN(DATE(A2+1,1,0),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+B2*7)
周结束: =MIN(DATE(A2+1,1,0),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+B2*7)
It seems to work well except that week 1
of 2019
begins on 31-12-2018
but my formula for the start date of the week 1
shows it as 01-01-2019
. 这似乎只是一周以及工作1
的2019
开始于31-12-2018
,但我一周的开始日期公式1
显示了它作为01-01-2019
。 What is the problem with my formula? 我的公式有什么问题?
只需从结束日期公式中减去6
=(MIN(DATE(A2+1,1,0),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+B2*7))-6
As I noted in my comment, the easiest way is just to subtract 6 from your end date. 正如我在评论中指出的那样,最简单的方法是从结束日期中减去6。 If your data is in a table, your formula would be =[@EndDate]-6
. 如果数据在表中,则公式将为=[@EndDate]-6
。 Otherwise, it would be something like =E2-6
. 否则,它将类似于=E2-6
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.