MS Access: Month Function
This MSAccess tutorial explains how to use the Access Month function with syntax and examples.
Description
The Microsoft Access Month function returns the month (a number from 1 to 12) given a date value.
Syntax
The syntax for the Month function in MS Access is:
Month ( date_value )
Parameters or Arguments
- date_value
- A valid date.
Returns
The Month function returns a numeric value between 1 and 12.
Applies To
The Month function can be used in the following versions of Microsoft Access:
- Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000
Example
Let's look at how to use the Month function in MS Access:
Month (#22/11/2003#) Result: 11 Month (#01/01/1998#) Result: 1
Example in VBA Code
The Month function can be used in VBA code in Microsoft Access.
For example:
Dim LMonth As Integer LMonth = Month(#12/03/2001#)
In this example, the variable called LMonth would now contain the value of 3.
Example in SQL/Queries
You can also use the Month function in a query in Microsoft Access.
For example:
In this query, we have used the Month function as follows:
Expr1: Month(#13/08/1985#)
and
Expr2: Month([CategoryDate])
The first Month function will extract the month value from the date 13/08/1985 and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.
For example:
MonthValue: Month(#13/08/1985#)
The results would now be displayed in a column called MonthValue.
The second Month function will extract the month value from the CategoryDate field and return the results in a column called Expr2.
Advertisements