WEEKDAY

The WEEKDAY function receives a date as an argument and returns a number identifying the day of the week to which it corresponds (from Monday to Sunday).

Syntax

WEEKDAY(
    date,
    return_type
)

Parameters
  • date: Date in datetime format.
  • return_type: Type of result to return. If it takes the value 1, the week starts on Sunday (day to which the number 1 is assigned) and ends on Saturday (day to which the number 7 is assigned). If it takes the value 2, the week starts on Monday (day to which the number 1 is assigned) and ends on Sunday (day to which the number 7 is assigned). Finally, if it takes the value 3, the week starts on Monday (the day to which the number 0 is assigned) and ends on Sunday (the day to which the number 6 is assigned).
Returned value

The WEEKDAY function returns an integer between 0 and 6 or between 1 and 7, depending on the type of result requested.

Additional Information

The date argument can be entered with the DATE function or with functions or expressions that return a value in datetime format. It can also be entered as a text string containing a date in any of the allowed formats, but this option should be avoided whenever possible to avoid unexpected results. If this option is used, the WEEKDAY function will use the locale and date and time settings of the client computer in order to interpret the text from which to extract the correct value. In this way, the following functions (which receive the same real number as an argument with a different format), will return the same value: 7 (corresponding to Saturday).

Día de la semana = WEEKDAY("15/10/2016")

Día de la semana = WEEKDAY(42658)

WEEKDAY function: Example of use

However -and as mentioned- the interpretation of a date such as "10/8/2016" will depend on the regional configuration. If it represents dates in "day/month/year" format, it will be interpreted as August 10, 2016. On the contrary, if it represents dates in "month/day/year" format, it will be interpreted as October 8, 2016.

If return_type takes any other value than 1, 2 or 3, the WEEKDAY function will return an error.

Examples

In this example, the date of a sale is read and the day of the week is returned with the return_type argument taking the value 2 (value for which Monday is represented by the number 1, Tuesday by the number 2,... and Sunday with the number 7):

Día de la semana = WEEKDAY(Tabla1[Fecha], 2)

WEEKDAY function: Example of use

Category
Date and time
Submitted by admin on Mon, 12/03/2018 - 23:30