[英]Excel: if date + days = specific weekday then
I want to write a if condition to sum 2 column date and see if it's equal to a specific day of the week. 我想编写一个if条件,以求和2列日期的总和,看看它是否等于一周中的特定日期。
Eg 例如
=If(weekday(A2)+B2 = 1, "Sunday", "Not Sunday") =如果(工作日(A2)+ B2 = 1,“星期日”,“非星期日”)
In words: If A2 + B2 = Sunday, then... 换句话说:如果A2 + B2 =星期日,则...
In this example, since A2 is Thursday and adding B2 which is 3 days, the result should be Sunday. 在此示例中,由于A2是星期四并加上B2,即3天,因此结果应该是星期日。 It should then return "Sunday".
然后应返回“ Sunday”。
The solution doesn't work because weekday(A2)+B2 is not equals to 1 (1 in weekday function refers to Sunday). 该解决方案不起作用,因为工作日(A2)+ B2不等于1(工作日函数中的1表示星期日)。 I can't specific weekday(A2)+B2 = 1 because A2 and B2 are subjected to changes (B can be 1 to 100).
我无法指定工作日(A2)+ B2 = 1,因为A2和B2会发生变化(B可以是1到100)。
How should I change my if-condition ? 我应该如何更改if条件 ?
WEEKDAY function has two parameters (second is optional). WEEKDAY函数有两个参数(第二个是可选的)。 You can add the second parameter equal 2 to get 7 as Sunday, and change formula to:
您可以添加第二个参数等于2,以将7作为星期日,并将公式更改为:
=If(weekday(A2,2)+B2 = 7, "Sunday", "Not Sunday")
Another possible solution is to add day offset inside WEEKDAY
另一种可能的解决方案是在
WEEKDAY
内添加日偏移量
=If(weekday(A2+B2) = 1, "Sunday", "Not Sunday")
Third option would be using MOD(...,7)
. 第三种选择是使用
MOD(...,7)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.