# Zellers congruance in Excel

Does anyone have an algorithm to calculate which day of the week a date falls on in Excel?
###### Who is Participating?

Commented:
Yes,

in a worksheet
=weekday(B4)

in VBA
Weekday(MyDateVar)

Sunday is 1, Monday 2, etc....
0

Commented:
cotec1,

The weekday function can return various ranges of values - dependent on the second parameter that you pass to the function, i.e.

= WeekDay (B4,1) will return a number from 1(Sunday) to 7(Saturday) [this is also the default value if you don't specify a parameter],

= Weekday (B4,2) will return a number from 1(Monday to 7(Sunday), and

= Weekday (B4,3) returns a number from 0(Monday) to 6(Sunday).

After you determine the numeric value of the weekday you are working with, by using the above =weekday(B4) worksheet function, you might then like to determine what the name of the weekday is.

The easiest way that I have found to accomplish that is by setting up a little table somewhere.  Using the 1(Sunday) to 7(Saturday) model, your table might look like:

1  Sunday
2  Monday
3
4
5
6
7  Saturday

Select all these cells and Name the range as WeekdayTable or similar.

Then to determine the name of the day, in another cell enter the formula:

= VLookUp(C4, WeekDayTable, 2).

But when its all said and done, by far the easiest way to determine the weekday is by using:

=TEXT("" & B4, "dddd")

This will return the day name from a date field in B4.

Crynoble, it is not normal practice to enter responses as Answers unless you are dead certain that your response exactly fits the question.  It is usual practice to just use the commenting facility.

Dave

0

Commented:
Hi cotec1

Suppose your date is in cell A1 all you would have to do is in any cell put =A1 then go to Format>Cells>Number>Custom and using anyone of the pre-defined formats as a starting point, type dddd.

This will now convert the date to the day of the week that it falls. e.g if the date is a Saturday then dddd format will return Saturday. ddd will return Sat and dd or d will return the day of the month.

Of course you could just applt]y this format to A1.

Good luck

antrat
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.