donviti
donviti

Reputation: 294

If Saturday OR Sunday then xls

I have figured out how to do a calculation if my Date Column is a Sunday. However, I want to Add in Saturday to this formula and am struggling mightily

=IF(WEEKDAY(A61)=1,0,IF(H61>8.5,H61-8.5,0))

What I would like to have done is figure out

  1. If Sunday (1) OR Saturday (6) then 0 Else IF(H61>8.5,H61-8.5,0)

Working Formula UPDATE:

=IF(WEEKDAY(A3,11)>=6,0,IF(H3>=8.5,8,IF(H3<6,H3,IF(H3<8,H3-0.5,"You have an Error"))))

also

=IF(WEEKDAY(A3,11)>5,0,IF(H3>8.5,H3-8.5,0))

Upvotes: 0

Views: 15020

Answers (2)

Marc
Marc

Reputation: 11613

Here's how you can use the OR():

=IF(OR(WEEKDAY(A10)=1,WEEKDAY(A10)=7),"Weekend","Not the Weekend")

So for your example:

=IF(OR(WEEKDAY(H61)=1,WEEKDAY(H61)=7),0,IF(H61>8.5,H61-8.5,0))

(you can change the weekday equality to check for 0 and 6 in your setup)

Upvotes: 2

Sam Axe
Sam Axe

Reputation: 33738

I am by no means an Excel expert.

As you have discovered, the Excel IF function takes 3 arguments: a condition, the 'true' action, and the 'false' action. You can chain IFs together. So in your case you could do (using some pseudo code):

IF(day = 1, 'do the sunday thing', IF(day = 6, 'do the saturday thing', 'do the weekday thing'))

Its messy and there are probably better ways to implement it.. but there you go.

Upvotes: 4

Related Questions