Contenido

# Función WeekDay

This function returns the number corresponding to the weekday represented by a serial date number that is generated by the DateSerial or the DateValue functions.

This help page describes the WeekDay function used in Basic scripts. If you are interested in the WeekDay function used in LibreOfficeDev Calc, refer to this help page.

### Sintaxis:

      WeekDay (SerialDate, [FirstDayOfWeek])

### Parámetros:

SerialDate: Integer expression that contains the serial date number that is used to calculate the day of the week.

FirstDayOfWeek: Integer value indicating which weekday should be considered as the first day of the week. The default value is 0, meaning that the system locale settings are used to determine the first day of the week.

The parameter FirstDayOfWeek accepts values ranging from 0 to 7. The table below describes the meaning of each possible value:

Valor | Constante de VBA | Descripción
--- | --- | ---
0 | vbUseSystemDayOfWeek | Use system locale settings
1 | vbSunday | Domingo (predeterminado)
2 | vbMonday | Lunes
3 | vbTuesday | Martes
4 | vbWednesday | Miércoles
5 | vbThursday | Jueves
6 | vbFriday | Viernes
7 | vbSaturday | Sábado

The VBA constants listed above are only available if VBA support has been enabled. For more information, read the VBASupport Statement help page.

### Devuelve tipo:

Entero

### Códigos de error:

5 Llamada a procedimiento no válida

### Ejemplo:

The following example uses the function Now() to determine the current weekday.

    Sub ExampleWeekDay
        Dim sDay As String
        ' Devolver y mostrar el día de la semana
        Select Case WeekDay( Now )
                Case 1: sDay="Sunday"
                Case 2: sDay="Monday"
                Case 3: sDay="Tuesday"
                Case 4: sDay="Wednesday"
                Case 5: sDay="Thursday"
                Case 6: sDay="Friday"
                Case 7: sDay="Saturday"
        End Select
        MsgBox "" + sDay,64,"Hoy es"
    End Sub

The following example illustrates the use FirstDayOfWeek parameter, assuming that Tuesday is the first day of the week.

      Dim someDay As Long
      ' La fecha 1 de enero de 2021 cayó en viernes
      someDay = DateSerial(2021, 01, 01)
      ' Genera «6», suponiendo que el domingo sea el primer día de la semana
      MsgBox WeekDay(someDay)
      ' Genera «4», suponiendo que el martes sea el primer día de la semana
      MsgBox WeekDay(someDay, 3)

Temas relacionados

Función DateSerial

Función DateValue

Función Now

DIASEM

¡Necesitamos su ayuda!