Fix Microsoft JET Date Syntax Errors in Classic ASP Queries
Question details
The user needs to correct a Microsoft JET date syntax error in a Classic ASP query that uses submitted form values.

- 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.
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.
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.
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.
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.
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.
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.
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.

Check an Access date literal when parameters are unavailable
Use this fallback to diagnose or construct a date literal when an existing query cannot yet be parameterized.
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.

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.




