How to Calculate the Last Day of Any Month in Microsoft Access
Question details
The user needs to dynamically calculate the last date of a given month and year within a Microsoft Access form or query.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Calculating end-of-month dates using numeric month and year fields in Access forms.
- Observed behavior
- Requires a robust formula that correctly handles months with varying numbers of days, including leap years and December-to-January rollovers.
Verify the exact names of the numeric fields or controls representing the year and month in your Access form or query before applying the calculation formulas.
Use the DateSerial Function to Return Day Zero
The most efficient way to find the last day of any month in Access is by requesting day 0 of the subsequent month using the DateSerial function.
The DateSerial function creates a date value from specified year, month, and day inputs. By setting the day argument to 0 and adding 1 to the month argument, Access automatically steps backward one day from the 1st of the next month, accurately yielding the last day of the target month.
Determine the numeric fields representing your year and month in your Access database, for example, [yearReporting] and [monthReporting].
In your query, control source, or VBA code, enter the expression: DateSerial([yearReporting], [monthReporting] + 1, 0).
If you need the last day of the current month based on today's date, use the expression: DateSerial(Year(Date()), Month(Date()) + 1, 0).

Calculate Explicitly for December
An alternative approach that explicitly handles the year rollover for December by incrementing the year and subtracting a day.
Manage Your Data with WPS Office Spreadsheet
While Microsoft Access is a traditional database tool, many data management and date calculation tasks can be handled more easily in a spreadsheet environment. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office, allowing you to perform advanced data analysis with a familiar user interface and seamless migration.

Frequently Asked Questions
Does the DateSerial function account for leap years automatically?
Yes, because DateSerial relies on the system's internal calendar. By requesting day 0 of March, it will correctly return February 29th during a leap year and February 28th in standard years.
Can I use the EOMONTH function in Microsoft Access?
No, the EOMONTH function is native to spreadsheet applications like Excel and WPS Spreadsheet, but it is not built into Microsoft Access. You must use the DateSerial workaround to achieve the same result in Access.
What happens if I pass a month value of 13 to DateSerial?
DateSerial is designed to handle out-of-range values gracefully. A month value of 13 is automatically interpreted as January of the following year, which is why adding 1 to December (12) works seamlessly.




