WEEKDAY()

SyntaxWEEKDAY(serial_number;return_type)

Definition. This function converts a date (serial number) into a weekday number. The weekday is returned as an integer from 1 (Sunday) through 7 (Saturday).

Arguments

Background. This function is useful for extracting the day of the week from a date.

Remember that you can use the TEXT() function (see Chapter 8) instead of the WEEKDAY() function to return a weekday as string:

=TEXT(TODAY(),"dddd")

See Also

For more information about saving dates in Excel, see the section titled The Excel Date System in Chapter 2.

Example. You might want to format Sundays in a date column in red. To do this, use conditional formatting. Select the date column. In Excel 2003 and earlier, select the Format/Conditional Formatting menu option and then select Formula in the list box. In Excel 2007 or Excel 2010, click the Conditional Formatting button in the Style group on the Start tab and select New Rule. Select Use A Formula To Determine Which Cells To Format as the rule type (see Figure 7-7).

Marking all Sundays by using the conditional formats in Excel 2007 and Excel 2010.

Figure 7-7. Marking all Sundays by using the conditional formats in Excel 2007 and Excel 2010.

Enter the formula

=WEEKDAY($B11,1)=1

and click the Format button to format the text (see Figure 7-8).

The Sundays in the date column are formatted in bold and red by using conditional formats.

Figure 7-8. The Sundays in the date column are formatted in bold and red by using conditional formats.

The following examples show how the type parameter works:

See Also

DAY(), HOUR(), MINUTE(), MONTH(), SECOND(), TODAY(), WEEKNUM(), YEAR()