MonthName Function (VB6)

Named Arguments

No

Syntax

MonthName monthnumber [, abbreviate]

monthnumber

Use: Required

Data Type: Long

The ordinal number of the month, from 1 to 12.

abbreviate

Use: Optional

Data Type: Boolean

A flag to indicate if an abbreviated month name should be returned.

Return Value

A String.

Description

Returns the month name of a given month. For example, 1 returns January, or if abbreviate is True, Jan.

Rules at a Glance

The default value for abbreviate is False.

Programming Tips and Gotchas

  • monthnumber must be an integer or a long; it can't be a date. Use DatePart("m", dateval) to obtain a month number from a date.

  • MonthName with abbreviate set to False is the equivalent of Format (dateval, "mmmm").

  • MonthName with abbreviate set to True is the equivalent of Format (dateval, "mmm").

See Also

Month Function, WeekdayName Function, DatePart Function

Get VB & VBA in a Nutshell: The Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.