FIX: Syntax Error When You Use ODBC Canonical Date Format as Parameter to SQL Stored Procedure (270586)



The information in this article applies to:

  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.5 SP1
  • Microsoft Data Access Components 2.6

This article was previously published under Q270586

SYMPTOMS

When you pass an ODBC canonical date literal as a parameter to a SQL Server stored procedure using the Microsoft SQL Server ODBC driver, a syntax error may be reported:
[Microsoft][ODBC SQL Server Driver]Invalid time format

RESOLUTION

A supported fix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Apply it only to computers that are experiencing this specific problem. This fix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next MDAC service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix should have the following file attributes or later:
   Date       Version   Size     File name    Platform
   -----------------------------------------------------
   08/01/2000 3.70.8.92 524,560  SQLSRV32.DLL   x86 
   08/01/2000 3.70.8.92  24,848  ODBCBCP.DLL    x86 
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

The ODBC canonical date escape sequence provides a generic way to pass a literal date to an ODBC driver. Because there is a single canonical date format, you can pass literal dates to any ODBC driver and be sure that the proper date will be stored in the database.

The exact format is as follows:
{d 'yyyy-mm-dd'}
				
Here is a simple example of using an ODBC canonical date in a SQL insert statement:
insert into table1 (f1) values ({d '1999-12-31'})
				

Steps to Reproduce Behavior

To reproduce the problem, use the ODBC Test utility (which is provided with the MDAC SDK) as follows:
  1. In the input window, paste the following statement, and then press CTRL+E to execute it:
    create procedure tmpDateTest( @d datetime ) as select @d
    						
    This calls the SQLExecDirect ODBC function and creates a stored procedure with datetime as an input parameter.
  2. Paste the following statement (replacing the previous one) and press CTRL+E:
    {call tmpDateTest({d '1999-12-31'}
    						
    This calls the stored procedure with a canonical date as an input parameter. The error is displayed in the output window.

Modification Type:MajorLast Reviewed:4/7/2006
Keywords:kbQFE KBHotfixServer kbBug kbprb KB270586