MS Access Day() Function
The Day()
function in MS Access extracts the day component from a date value. It's a very useful function for working with date data and performing date-based analysis or filtering.
Day(): Definition and Usage
Day()
takes a date value as input and returns an integer representing the day of the month. The returned value will always be between 1 and 31 (inclusive). It's commonly used to filter records based on specific days of the month, to group data by day, or to perform day-related calculations.
Syntax
Syntax
Day(date)
Parameter Values
Parameter | Description |
---|---|
date |
A date value (can be a date literal like #05/17/2017# , a date field from a table, or an expression resulting in a date). This is required. |
Examples
Extracting the Day from a Specific Date
This example extracts the day (17) from the date May 17th, 2017.
Syntax
SELECT Day(#05/17/2017#);
Output
17
Extracting the Day from Today's Date
This example gets the current day of the month.
Syntax
SELECT Day(Date());
Output
(The current day of the month, a number between 1 and 31)
Extracting the Day from a Table Column
This example retrieves the day of the month of the birthdate for each employee from the 'Employees' table (assuming a table named 'Employees' exists with a 'BirthDate' column).
Syntax
SELECT Day(BirthDate) FROM Employees;
Output
(A list of integers representing the day of the month of each employee's birthdate.)