Given a date, how do I get the day of the week (e.g. "Monday") into a cell in Excel?
The answer given above is only working by fluke because Excel thinks that 1/1/1900 was a Sunday* and by default Excel is using Sunday as first day of week for the Weekday function.
What you are actually calculating in that method is the day of the week as a number, then formatting that as a day based on that number interpreted as a date. Eg if your date is 1/2/2003 and you use the WEEKDAY function, this results in 7 (=Saturday). When you then format this as "dddd" you are actually getting the day name of the 7th day in Excel since its "epoch", ie 7/1/1900, which happens to be a Saturday*. This formula will break if someone opens it who has the option selected to use the 1904-based date system, as 1/1/1904 was not a Sunday, but a Friday. (yes I know hardly anyone uses that, but you don't want to build a solution which relies on that do you?)
You can make the formula shorter, faster and more robust simply by using
You could of course just format the date cells themselves with a custom format as already suggested, depending on whether you really need this in a separate column or not. I often use date formats such as
ddd dd mmm yyyy
to give eg Sat 01 Feb 2003 so the date is explicit but shows the weekday name as well.
Using a second column and a TEXT function is essential if you want to use the weekday explicitly somewhere in a mail merge (for example), similarly for things like currencies and so on Excel > Word merging passes the actual underlying stored value rather than the on-screen formatted version, so regardless of the cell format, Word sees some horrible number. A true text field is passed 'as is' and displays properly in Word.
*in fact it is a Monday but Excel was written to match the incorrect dates in Lotus 1-2-3 which treated 1900 as a leap year when it is not.
I found that nesting
IF statements can be cumbersome, but it does work. If, however, you'd like to save a little typing, you may try this:
Or, if you need full names:
In this example, "A2" can be whatever cell (or formula) contains the date in question. For instance:
would print the three letter abbreviation for whatever today is.
you can also localize the answer by using [$nnn] before the format (so the custom code is: [$nnn]dddd;@). change nnn with the proper language code. i don't have the list, but somehow, english code is -409 (and my local is -421).
i think you can experiment with Number format, change the language field, then change it back to custom format.
WEEKDAY Function can be used in Vba Codes . For example :
Label1.Caption = WeekdayName(Weekday(TextBox1, 0), False, 0)
Day name is gotten from TextBox1 in above example. Result is "Monday" .
I used this function in when I created userform about date entry to active cell with right-click menu.