简体   繁体   English

Excel:如果日期+天=特定工作日,则

[英]Excel: if date + days = specific weekday then

Current table : 当前表
在此处输入图片说明

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.

相关问题 如何从特定日期减去并使其落在工作日,同时在减法中计算周末天数? - How to subtract from a specific date and have it land on a weekday while counting weekend days in the subtraction? Excel公式:从工作日和工作日中查找日期 - Excel formula: Find Date from Weeknum and weekday SharePoint 公式:[创建]+60 天 = 延期日期(但需要是工作日) - SharePoint Formula: [Created]+60 days = Extension Date (but need it to be a weekday) 在Excel中,如何计算日期范围之间的天数,仅计算一周中的特定天数 - In Excel, how to calculate # of days between a date range, counting only specific days of week 如果工作日等于工作日excel,则求和 - sum if weekday is equal to the weekday excel Excel 从日期中减去 X 天,然后找到最后一个特定工作日日期 - Excel subtract X days from date and then find last specific workday date Excel VBA-如果文件创建日期的星期几与单元格值匹配? - Excel VBA - if weekday of file created date matches cell value? 使用Excel宏在文件名中保存具有上一个工作日日期的文件 - Using an Excel macro to save a file with the previous weekday date in the filename 在 Google 表格/Excel 中从工作日获取下一个日期 - Get next date from weekday in Google Sheets/Excel 日期范围内的天数-Excel - number of days in date range - excel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM