MS Access MonthName() Function
The MonthName()
function in MS Access returns the name of a month, given a numerical representation of the month (1 for January, 2 for February, etc.). This is helpful for displaying months in a more user-friendly format or for performing operations based on the month.
MonthName(): Definition and Usage
MonthName()
takes an integer (1-12) representing the month as input and returns the corresponding month name as a string. You can optionally specify whether to abbreviate the month name.
Syntax
Syntax
MonthName(number, abbreviate)
Parameter Values
Parameter | Description |
---|---|
number |
An integer from 1 to 12 representing the month (1=January, 2=February,... 12=December). This is required. |
abbreviate (Optional) |
A boolean value (True or False). True returns an abbreviated month name (e.g., "Jan"); False (default) returns the full name (e.g., "January"). |
Examples
Getting the Full Month Name
This example retrieves the full name of the third month (March).
Syntax
SELECT MonthName(3);
Output
March
Getting the Abbreviated Month Name
This example retrieves the abbreviated name of the third month.
Syntax
SELECT WeekdayName(3, True);
Output
Mar