Month Function

See Also5A9OT4B              Example1LPYIWS>Low

Returns an integer between 1 and 12, inclusive, that represents the month of the year for a date argument.

Syntax

Month(dateexpression)

Remarks

The dateexpression part of the syntax is any numeric expression71RISN or string expression1330R89 that can represent a date and/or time from January 1, 100 through December 31, 9999, where January 1, 1900 is 2.  Numbers to the left of the decimal point in dateexpression represent the date; numbers to the right represent the time.  Negative numbers represent dates prior to December 30, 1899.

If dateexpression is Null1DDW7C0, this function returns a Null.


See Also

Date, Date$ Functions3E3X9E

Date, Date$ Statements3E3X9R

Day FunctionLANDAY

Hour FunctionGU67IG

Minute Function5OWKHCJ

Now FunctionLANNOW

Second FunctionC46EYJ

Weekday FunctionM393JM

Year FunctionGUFX5G


Month Function Example

The example uses the Month function to determine the month of the year.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim MonthNum, MonthSuffix, Msg, Serial      ' Declare variables.

   Serial = Now                          ' Get date serial number.

   MonthNum = Month(Serial)              ' Get current month number.

   Select Case MonthNum                  ' Get proper suffix

      Case 1                             '  for each number.

         MonthSuffix = "st"

      Case 2

         MonthSuffix = "nd"

      Case 3

         MonthSuffix = "rd"

      Case Else

         MonthSuffix = "th"

   End Select

   Msg = Format(Serial, "mmmm") & " is the " & MonthNum

   Msg = Msg & MonthSuffix & " month of the year."

   MsgBox Msg                            ' Display message.

End Sub