Export (0) Print
Expand All

WEEKDAY Function

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns a number from 1 to 7 identifying the day of the week of a date. By default the day ranges from 1 (Sunday) to 7 (Saturday).

WEEKDAY(<date>, <return_type>)

Term

Definition

date

A date in datetime format.

Dates should be entered by using the DATE function, by using expressions that result in a date, or as the result of other formulas.

return_type

A number that determines the return value:

Return type

Week begins

1

Week begins on Sunday (1) and ends on Saturday (7).

2

Week begins on Monday (1) and ends on Sunday (7).

3

Week begins on Monday (0) and ends on Sunday (6).

An integer number from 1 to 7.

In contrast to Microsoft Excel, which stores dates as serial numbers, DAX works with dates and times in a datetime format. If you need to display dates as serial numbers, you can use the formatting options in Excel.

You can also type dates in an accepted text representation of a date, but to avoid unexpected results, it is best to convert the text date to a datetime format first.

When the date argument is a text representation of the date, the function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. If the current date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2009", is interpreted as a datetime value equivalent to January 8th of 2009. However, if the current date/time settings represent dates in the format of Day/Month/Year, then the same string would be interpreted as a datetime value equivalent to August 1st of 2009.

The following example gets the date from the [HireDate] column, adds 1, and displays the weekday corresponding to that date. Because the return_type argument has been omitted, the default format is used, in which 1 is Sunday and 7 is Saturday. If the result is 4, the day would be Wednesday.

=WEEKDAY([HireDate]+1)
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft