How to Count Access Records by Date While Ignoring Time
Question details
The user needs to count and group database records by date while ignoring the time portion of a Date/Time field, in order to avoid a data type mismatch error.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Grouping and aggregating database records based on a Date/Time field using SQL queries.
- Observed behavior
- Directly grouping by the Date/Time field or improperly applying the DateValue function results in a 'Data type mismatch in criteria expression' error.
Verify that your source field is formatted as a true Date/Time data type in your Access table design, rather than a Short Text or Long Text field.
Use the Int() Function to Extract the Date
The most reliable and efficient way to strip the time from an Access Date/Time field for grouping is by using the Int() function.
In Microsoft Access, Date/Time values are stored as floating-point numbers where the integer portion represents the day and the decimal portion represents the time. Using Int() cleanly removes the time component without causing data type mismatch errors.
Open your Access database, navigate to the Create tab, and click Query Design. Close the Add Tables dialog and switch to SQL View from the bottom right corner or the Home tab.
Modify your SELECT statement to wrap your date field with the Int() function. For example: SELECT Int([CollectionDateAndTime]) AS SampleDate.
Include your Count function and group by the exact same Int() expression. The final query should look like: SELECT Int([CollectionDateAndTime]) AS SampleDate, Count(*) AS SampleCount FROM Samples GROUP BY Int([CollectionDateAndTime]);
Click the Run button (!) in the query design ribbon to view your aggregated records correctly grouped by date.

Use DateValue Combined with the Format Function
If you prefer using DateValue, you must first convert the Date/Time field into a string format to prevent data type mismatch errors.
Looking for an Easier Way to Group Data? Try WPS Office
While Microsoft Access handles complex relational queries, most everyday data grouping, counting, and date-filtering tasks can be accomplished effortlessly using advanced spreadsheets. WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office, featuring powerful Pivot Tables to group data by date without writing a single line of SQL.
- 1. Export and Open Data: Export your Access table as a CSV or XLSX file and open it in WPS Spreadsheets.
- 2. Create a Pivot Table: Highlight your data range, go to the Insert tab, and click PivotTable.
- 3. Group by Date Easily: Drag your Date/Time field to the Rows area and any other field to Values. Right-click any date cell in the Pivot Table, select Group, and choose Days to instantly ignore the time component.

Frequently Asked Questions
Why does DateValue cause a 'Data type mismatch' error in Microsoft Access?
The DateValue function is specifically designed to parse string arguments. When you pass a native Date/Time field directly into it within a GROUP BY clause, Access fails to process the underlying numeric data type correctly, throwing a mismatch error.
How does the Int() function separate the date from the time?
In Microsoft Access, Date/Time values are stored as double-precision floating-point numbers. The integer portion represents the specific date, while the decimal portion represents the time of day. Using Int() drops the decimal, leaving only the date.
Can I group Access records by month instead of exact dates?
Yes. You can use the Format() function to group by month and year. For example, grouping by Format([YourDateField], 'yyyy-mm') will aggregate all records for a specific month, entirely ignoring both the specific day and the time.
How do I check if my field is a Date/Time type and not Text?
Right-click your table in the Navigation Pane and select Design View. Look at the Data Type column next to your field name; it should explicitly say 'Date/Time' or 'Date/Time Extended', not 'Short Text' or 'Long Text'.




