DateAndTime.Year(DateTime) Método
Definição
Retorna um valor inteiro de 1 a 9999 que representa o ano.Returns an integer value from 1 through 9999 representing the year.
public:
static int Year(DateTime DateValue);
public static int Year (DateTime DateValue);
static member Year : DateTime -> int
Public Function Year (DateValue As DateTime) As Integer
Parâmetros
- DateValue
- DateTime
Obrigatórios.Required. Um valor Date do qual você deseja extrair o ano.A Date value from which you want to extract the year.
Retornos
Um valor inteiro de 1 a 9999 que representa o ano.An integer value from 1 through 9999 representing the year.
Exemplos
O exemplo a seguir usa a Year função para obter o ano a partir de uma data especificada.The following example uses the Year function to obtain the year from a specified date. No ambiente de desenvolvimento, o literal de data é exibido em formato de data abreviada usando as configurações de localidade do seu código.In the development environment, the date literal is displayed in short date format using the locale settings of your code.
Dim thisDate As Date
Dim thisYear As Integer
thisDate = #2/12/1969#
thisYear = Year(thisDate)
' thisYear now contains 1969.
Comentários
Você também pode obter o ano chamando DatePart e especificando DateInterval.Year para o Interval argumento.You can also obtain the year by calling DatePart and specifying DateInterval.Year for the Interval argument.