Access: MonthName Function

In Access, the MonthName function returns a string containing the specified month.

The syntax for the MonthName function is:

MonthName ( month [, abbreviate] )

The required month argument is a value from 1 to 12, representing the month. The abbreviate argument is optional. It accepts a boolean value, that indicates if the month name is to be abbreviated. If omitted, the default is False, which means that the month name is not abbreviated.

Examples

MonthName (5)               returns 'May' 
MonthName (5,False)       returns 'May'
MonthName (1,True)        returns 'May'

VBA Code

Dim MyMonth As Integer 
MyMonth = MonthName(3,False)

This example uses the MonthName function to obtain the months name from a specified month.  Now the MyMonth variable would contain the value of ‘March’.

SQL query

You can also use the MonthName function in a query.

SELECT MonthName(1,True) AS Expr1 
FROM Orders

Note

You cannot test this function online. It works in Access only.

admin

admin

Leave a Reply

Your email address will not be published.