Others

Fix Microsoft JET Date Syntax Errors in Classic ASP Queries

Tauseeq MagsiTauseeq Magsi Nov 22, 2026 868 views

Question details

The user needs to correct a Microsoft JET date syntax error in a Classic ASP query that uses submitted form values.

Fix Microsoft JET Date Syntax Errors in Classic ASP Queries
Product
Microsoft JET database engine and Microsoft Access
Device & OS
not provided
Scenario
A Classic ASP page builds an Access SQL query from date and time values submitted through a form.
Observed behavior
The query reports a syntax error in a date expression when the constructed date literal is invalid or missing.
Before you start

Identify the form fields used for the date and time, their expected input formats, and the Access date/time column being queried. Check whether the column stores a time as well as a date, since an exact comparison includes both.

Solution 1Recommended

Validate the form values and use an ADODB parameter

Use a typed parameter to pass a validated date to Access without concatenating it into SQL.

1
Check the submitted values

In the Classic ASP page, read the date with Request.Form and reject an empty value. Require a known input format, such as yyyy-mm-dd, and validate its components as a real calendar date before converting them to a VBScript Date value.

2
Validate the time separately

If the form includes a time field, check Request.Form for a valid time in the expected format and combine it with the validated date. If no time is supplied, decide explicitly whether midnight is appropriate.

3
Create a parameterized command

Create an ADODB.Command, assign its ActiveConnection, and set CommandText to a query such as SELECT * FROM [Events] WHERE [EventDate] = ?. Replace the table and column names with those in your database.

4
Bind and execute the date

Append an input date parameter using cmd.Parameters.Append cmd.CreateParameter("pDate", 7, 1, , parsedDate), where parsedDate is the validated VBScript Date value. Execute the command with cmd.Execute. For multiple question-mark placeholders, append parameters in their SQL order.

5
Test the comparison

Submit a known valid date through the form and inspect the result. If the Access field contains times and the goal is to match a whole day, use a range from the selected date at midnight up to, but not including, the next midnight instead of an exact equality comparison.

Validate the form values and use an ADODB parameter
Avoid locale-dependent conversion: Do not rely on an ambiguous value such as 01/02/2025 being interpreted the same way on every server. Parse the agreed input format explicitly and check that the resulting date components match the submitted components.
Free Microsoft Office alternative

Work with Office documents in WPS Office

WPS Office is a free, lightweight alternative for everyday documents, spreadsheets, and presentations. Its familiar interface and Microsoft Office format support make it easier to move existing files. It does not fix JET errors or replace Access and Classic ASP.

Review date-related data in a familiar spreadsheet interfaceOpen and edit common Microsoft Office formats, including DOCX, XLSX, and PPTXUse free tools for documents, spreadsheets, and presentationsMove existing Office files into a lightweight, easy-to-use workspace
QA img-9

Frequently Asked Questions

Why does JET report a syntax error in a date expression?

The SQL may contain an empty or invalid date, incorrect number-sign delimiters, or a value interpreted differently because of its format. Inspect the constructed query during testing and validate the form values before using them.

How do I pass a date to an Access query from Classic ASP?

Use an ADODB.Command with a question-mark placeholder in CommandText, then append a typed input date parameter containing a validated VBScript Date value. Append multiple parameters in the same order as their placeholders.

Why does an exact date query return no records?

An Access Date/Time field may contain a time as well as a date. To find all records on a day, use a range starting at that day's midnight and ending before the next day's midnight.

Can I put a date directly into Access SQL?

Access SQL supports date literals enclosed in number signs, such as #2025-03-08#. Build the literal only from validated components, and prefer a typed parameter when the date comes from a form.