MS Access: Day Function
This MSAccess tutorial explains how to use the Access Day function with syntax and examples.
Description
The Microsoft Access Day function returns the day of the month (a number from 1 to 31) given a date value.
Syntax
The syntax for the Day function in MS Access is:
Day ( date_value )
Parameters or Arguments
- date_value
- A valid date.
Returns
The Day function returns a numeric value between 1 and 31.
Applies To
The Day 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 Day function in MS Access:
Day (#22/11/2003#) Result: 22 Day (#01/01/1998#) Result: 1
Example in VBA Code
The Day function can be used in VBA code in Microsoft Access.
For example:
Dim LDay As Integer LDay = Day(#12/03/2001#)
In this example, the variable called LDay would now contain the value of 12.
Example in SQL/Queries
You can also use the Day function in a query in Microsoft Access.
For example:
In this query, we have used the Day function as follows:
Expr1: Day(#13/08/1985#)
and
Expr2: Day([CategoryDate])
The first Day function will extract the day value (1 to 31) for 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:
DayValue: Day(#13/08/1985#)
The results would now be displayed in a column called DayValue.
The second Day function will extract the day value from the CategoryDate field and return the results in a column called Expr2.
Advertisements