DateAndTime.Weekday(DateTime, FirstDayOfWeek) Método

Definição

Retorna um valor inteiro que contém um número que representa o dia da semana.Returns an integer value containing a number representing the day of the week.

public static int Weekday (DateTime DateValue, Microsoft.VisualBasic.FirstDayOfWeek DayOfWeek = Microsoft.VisualBasic.FirstDayOfWeek.Sunday);
static member Weekday : DateTime * Microsoft.VisualBasic.FirstDayOfWeek -> int
Public Function Weekday (DateValue As DateTime, Optional DayOfWeek As FirstDayOfWeek = Microsoft.VisualBasic.FirstDayOfWeek.Sunday) As Integer

Parâmetros

DateValue
DateTime

Obrigatórios.Required. Um valor Date para o qual você deseja determinar o dia da semana.A Date value for which you want to determine the day of the week.

DayOfWeek
FirstDayOfWeek

Opcional.Optional. Um valor escolhido na enumeração de FirstDayOfWeek que especifica o primeiro dia da semana.A value chosen from the FirstDayOfWeek enumeration that specifies the first day of the week. Se não for especificado, é usado Sunday.If not specified, Sunday is used.

Retornos

Int32

Um valor inteiro que contém um número que representa o dia da semana.An integer value containing a number representing the day of the week.

Exceções

DayOfWeek é menor que 0 ou maior que 7.DayOfWeek is less than 0 or more than 7.

Exemplos

O exemplo a seguir usa a Weekday função para obter o dia da semana de uma data especificada.The following example uses the Weekday function to obtain the day of the week from a specified date.

Dim oldDate As Date
Dim oldWeekDay As Integer
oldDate = #2/12/1969#
oldWeekDay = Weekday(oldDate)
' oldWeekDay now contains 4 because thisDate represents a Wednesday.

Comentários

O valor retornado pela Weekday função corresponde aos valores da FirstDayOfWeek enumeração; ou seja, 1 indica domingo e 7 indica sábado.The value returned by the Weekday function corresponds to the values of the FirstDayOfWeek enumeration; that is, 1 indicates Sunday and 7 indicates Saturday.

Observação

Weekday usa a configuração de calendário atual da CurrentCulture propriedade da CultureInfo classe no System.Globalization namespace.Weekday uses the current calendar setting from the CurrentCulture property of the CultureInfo class in the System.Globalization namespace. Os CurrentCulture valores padrão são determinados pelas configurações do painel de controle .The default CurrentCulture values are determined by Control Panel settings.

O DayOfWeek argumento pode ter uma das configurações a seguir.The DayOfWeek argument can have one of the following settings.

Valor de enumeraçãoEnumeration value ValorValue DescriçãoDescription
FirstDayOfWeek.System 00 Primeiro dia da semana especificado nas configurações do sistemaFirst day of week specified in system settings
FirstDayOfWeek.Sunday 11 Domingo (padrão)Sunday (default)
FirstDayOfWeek.Monday 22 Segunda-feira (compatível com ISO Standard 8601, seção 3,17)Monday (complies with ISO standard 8601, section 3.17)
FirstDayOfWeek.Tuesday 33 Terça-feiraTuesday
FirstDayOfWeek.Wednesday 44 Quarta-feiraWednesday
FirstDayOfWeek.Thursday 55 Quinta-feiraThursday
FirstDayOfWeek.Friday 66 FridayFriday
FirstDayOfWeek.Saturday 77 SábadoSaturday

Aplica-se a

Confira também