Microsoft Knowledge Base Email Alertz

(270586) - 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

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 270586 - Last Review: April 7, 2006 - Revision: 4.1

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

This article was previously published under Q270586

On This Page

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:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)
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.

APPLIES TO
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.5 Service Pack 1
  • Microsoft Data Access Components 2.6
Keywords: 
kbqfe kbhotfixserver kbbug kbprb KB270586
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate