Others

Return the Last Day of a Month in an Access Date Formula

Aamir Naveed AkramAamir Naveed Akram Oct 28, 2026 869 views

Question details

The user needs a method to calculate and return the exact last day of a specified month within a Microsoft Access calculated field using a date formula.

How to Return the Last Day of a Month in an Access Date Formula
Product
Microsoft Access
Device & OS
not provided
Scenario
Creating a dynamic calculated field in Microsoft Access where the final output needs to be the last day of a given month instead of the default first day.
Observed behavior
Basic date formulas typically target or default to the first day of the month; a specific configuration of the DateSerial function is required to retrieve the last day accurately.
Before you start

Familiarize yourself with the Expression Builder in Microsoft Access and ensure you understand how to reference existing date fields in your database queries.

Solution 1Recommended

Use the DateSerial Function with a Day Argument of 0

By setting the day argument to 0 in the DateSerial function, you instruct Microsoft Access to return the final day of the preceding month, automatically handling variations in month lengths and leap years.

The DateSerial function normally expects three arguments: Year, Month, and Day. While you might typically input a specific calendar day, setting the Day argument to 0 is a built-in technique that forces the function to step back one day from the first of the specified month, thereby yielding the last day of the previous month.

1
Open your query in Design View

Launch Microsoft Access, open your database, and navigate to the query where you want to add the new calculated field. Right-click the query and select 'Design View'.

2
Access the Expression Builder

Click in an empty 'Field' cell in the query design grid, then click the 'Builder' button on the Query Design ribbon tab.

3
Enter the DateSerial formula

Input the DateSerial formula by adding 1 to your target month and setting the day to 0. For example, to find the last day of the current month, use: `=DateSerial(Year(Date()), Month(Date()) + 1, 0)`.

4
Implement nested conditions for complex logic

For specialized scenarios like quarterly or yearly calculations, use nested IIf functions. For example: `=IIf([SalesTax]="Qtly",DateSerial(Year(Date()),Int((Month(Date())-1)/3)*3+5,0),IIf([SalesTax]="Yrly",DateSerial(Year(Date())+1,Nz([YrlyM],1)+1,0),Null))`.

Use the DateSerial Function with a Day Argument of 0
Handles Leap Years: This 'Day 0' trick automatically handles leap years. If you are targeting the end of February during a leap year, DateSerial correctly evaluates and returns February 29th.
Free Microsoft Office alternative

Easily Analyze Exported Database Records with WPS Office

While Microsoft Access is a powerful tool for structuring databases, deep data analysis and advanced reporting are often easier in a spreadsheet. WPS Office provides a free, lightweight suite that acts as the perfect alternative to Microsoft Office, complete with powerful spreadsheet functions to continue your date logic work seamlessly.

  1. 1. Download and Install WPS Office: Visit the official WPS website to download and install WPS Office Free on your device.
  2. 2. Export your Access data: In Microsoft Access, select your table or query, navigate to External Data, and export it as an Excel file (.xlsx).
  3. 3. Analyze in WPS Spreadsheet: Open your exported data file in WPS Spreadsheet and use intuitive formulas like =EOMONTH() to manipulate and track your critical date fields.
Highly compatible with Microsoft Excel (.xlsx) formats for opening exported Access queries directly.Includes WPS Spreadsheet with dedicated date functions like EOMONTH to easily calculate month-end dates.Completely free and lightweight, making it an ideal Microsoft Office alternative.Features a familiar user interface ensuring a quick learning curve and seamless migration.
microsoft office alternative - wps office

Frequently Asked Questions

Does this DateSerial trick work for calculating the end of the year?

Yes, by setting the month argument to 13 and the day argument to 0 (e.g., `=DateSerial(Year(Date()), 13, 0)`), the function will return December 31st of the current year.

Can I use the exact same formula in spreadsheet software like Excel or WPS Spreadsheet?

While the logic of using a '0' day works in spreadsheet software via the `DATE` function (e.g., `=DATE(Year, Month + 1, 0)`), spreadsheets also offer a dedicated and simpler `EOMONTH` function specifically designed for this purpose.

Why is my Access query returning a syntax error on the DateSerial formula?

Check your field references and comma placements. Ensure that any field names referenced in your expression (like `[SalesTax]`) are spelled exactly as they appear in the underlying table or query, and that brackets are used correctly.