Carol.Kar
Carol.Kar

Reputation: 5355

`WEEKDAY` function gives the wrong value?

I am in London GMT Time Zone.

If I plug into my excel:

=IF(OR(WEEKDAY(F20)=6;WEEKDAY(F20)=7);TRUE;FALSE)

enter image description here

I get TRUE back which is clearly wrong because it is a Friday in my Time Zone!

However, this is wrong see here:

29.12.2006

Why is this error is excel?

I appreciate your answer!!!

Upvotes: 2

Views: 6532

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1502446

WEEKDAY(F20) will be 6 - which is Friday.

From the documentation:

The day is given as an integer, ranging from 1 (Sunday) to 7 (Saturday), by default.

So 6 is a Friday.

It looks like you should be checking whether WEEKDAY(F20) is 1 or 7, if you're trying to find out if it's a weekend.

If you want to use Monday (1) - Sunday (7) you need to pass in a second value of 2 to the function:

WEEKDAY(F20, 2)

(Again, see the documentation.)

Upvotes: 10

Related Questions