Função Month

Retorna um número inteiro entre 1 e 12, inclusive, representando o mês do ano.

Sintaxe

Month(date)

Argumentos:

Date: Obrigatório. Qualquer expressão que possa representar uma data.

Formatos de Data Suportados:

  • MM-DD-YYYY
  • MM/DD/YYYY
  • DD-MM-YYYY
  • DD/MM/YYYY
  • YYYY-MM-DD
  • YYYY/MM/DD

Comentários

O exemplo a seguir usa a função Month para retornar o mês atual:

Exemplo 1:

Dim MyVar
MyVar = Month(Now)
'Output: If current month is January, then it returns 1

Exemplo 2:

Dim MyDate, MyMonth
MyDate = "21/01/2025"
MyMonth = Month(MyDate)
'Output: 1 (January)

Exemplo 3:

Dim MyDate1, MyMonth1
MyDate1 = DateAdd("m", 5, "21/01/2025") 
MyMonth1 = Month(MyDate1)                 
'Output: 6 (June)

Exemplo 4:

Dim MyDateTime2, MyMonth2
MyDateTime2 = "21/01/2025 18:45:30"   ' Date-Time value.
MyMonth2 = Month(MyDateTime2)           ' Returns the month part of the date-time value.
'Output: 1 (January)