Reputation: 707
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.
E.g.
=If(weekday(A2)+B2 = 1, "Sunday", "Not Sunday")
In words: If A2 + B2 = Sunday, then...
In this example, since A2 is Thursday and adding B2 which is 3 days, the result should be Sunday. It should then return "Sunday".
The solution doesn't work because weekday(A2)+B2 is not equals to 1 (1 in weekday function refers to Sunday). I can't specific weekday(A2)+B2 = 1 because A2 and B2 are subjected to changes (B can be 1 to 100).
How should I change my if-condition?
Upvotes: 0
Views: 2518
Reputation: 5990
WEEKDAY function has two parameters (second is optional). You can add the second parameter equal 2 to get 7 as Sunday, and change formula to:
=If(weekday(A2,2)+B2 = 7, "Sunday", "Not Sunday")
Another possible solution is to add day offset inside WEEKDAY
=If(weekday(A2+B2) = 1, "Sunday", "Not Sunday")
Third option would be using MOD(...,7)
.
Upvotes: 1