Name
MonthName Function
Class
Microsoft.VisualBasic.DateAndTime
Syntax
MonthName(month[,abbreviate])
-
month(required; Integer) The ordinal number of the month, from 1 to 12
-
abbreviate(optional; Boolean) A flag to indicate if an abbreviated month name should be returned
Return Value
String containing the name of the specified month
Description
Returns the month name of a given month. For example, a
month of 1 returns January or (if
abbreviate is True)
Jan.
Rules at a Glance
The default value for abbreviate is
False.
Example
Public Function GetMonthName(dat As Date) As String Dim iMonth As Integer = Month(dat) GetMonthName = MonthName(iMonth) End Function
Programming Tips and Gotchas
monthmust be an integer; it cannot be a date. UseDatePart("m",dateval)to obtain a month number from a date.If
monthhas a fractional portion, it is rounded before calling the MonthName function.MonthName with
abbreviateset toFalseis the equivalent ofFormat(dateval,"mmmm").MonthName with
abbreviateset toTrueis the equivalent ofFormat(dateval,"mmm").