Use a Date Range in an Excel Microsoft Query Parameter
Question details
Use a start date and an end date to filter an Excel Microsoft Query instead of passing two dates through a single parameter.
- Product
- Microsoft Excel Microsoft Query
- Device & OS
- not provided
- Scenario
- An existing query uses a worksheet cell as a date parameter, and the user wants to filter records by a date range.
- Observed behavior
- The query returns a syntax error after the reference cell is changed from one date to two dates.
Identify the query's date column and enter the start and end dates in two separate worksheet cells. Check that both cells contain valid dates and that the start date is not later than the end date.
Change the query to use two date parameters
Use this approach when a query that previously matched one date needs to return records within a date range.
A single parameter normally supplies one value, so placing two dates in its reference cell does not automatically create a range. Use a between comparison with separate start and end parameters, or equivalent greater-than-or-equal-to and less-than-or-equal-to conditions.
In Excel, select a cell in the query results and open the query or connection properties from the Data tab. Use the available edit-query option to open the query in Microsoft Query; menu names vary by Excel version.
In Microsoft Query, edit the criteria for the date column. Change the equal-to comparison to between and provide separate parameter placeholders for the start and end dates. If editing SQL, an equivalent condition is `DateColumn >= ? AND DateColumn <= ?`; use the actual column name and syntax required by the data source.
Return the query to Excel, then open its connection or external data properties and select Parameters. Bind the first date parameter to the start-date cell and the second to the end-date cell. If prompted while editing the query, supply the dates in the format expected by the data source.
Select Data > Refresh All and confirm that the returned records fall within the intended date range. If an error remains, check the parameter order, date values, and data-source date syntax.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Microsoft Office formats, making it easy to move everyday spreadsheet work. It does not repair Excel Microsoft Query connections.

Frequently Asked Questions
Can I put both dates in one parameter cell?
A Microsoft Query parameter normally accepts one value. Put the start and end dates in separate cells and bind them to separate query parameters.
Where do I connect the query parameters to worksheet cells?
Select a cell in the query results, open the connection or external data properties from Excel's Data tab, and choose Parameters. The exact menu names depend on the Excel version and connection type.
Why are some records on the end date missing?
The source column may include times, while the end-date parameter represents midnight. Change the end condition to be less than the following day so records throughout the end date are included.
Why does the query still report a syntax error?
Check the SQL or criteria in Microsoft Query for the correct column name, two separate parameter placeholders, and date syntax supported by the data source. Also verify the parameter order and that both worksheet cells contain valid dates.




