Siebel VB Language Reference > VB Language Reference >

Month Function

This standard VB function returns an integer for the month component (1-12) of a date-time value.





Any numeric or string expression that can evaluate to a date-time or date value


If the expression evaluates to a date-time or date value, the month component of that value; otherwise 0.


Date can be of any type, including string, and the Month function attempts to convert the input value to a date-time value.

For Month to function without an error, the values passed to it must be in some form that can be interpreted as a time or date-time value. Thus, 11/20, or 11-20-2001 returns valid results, but 1120 returns a 0.

The return value is a variant of vartype 2 (integer). If the value of date is null, a variant of vartype 1 (null) is returned.


This example finds the month (1-12) and day (1-31) values for this Thursday.

Sub Button_Click
      Dim x As Integer, Today As Variant
      Dim msgtext
      Today = DateValue(Now)
      Let x = 0
      Do While Weekday(Today + x) <> 5
         x = x + 1
      msgtext = "This Thursday is: " & Month(Today + x) &"/" _
            & Day(Today + x)
End Sub

See Also

Date Statement
DateSerial Function
DateValue Function
Day Function
Hour Function
Minute Function
Now Function
Second Function
Time Statement
TimeSerial Function
TimeValue Function
WebApplet_InvokeMethod Event
Year Function

Siebel VB Language Reference