Microsoft KB Archive/156139

= How to use the SQL Server DateTime parameter to avoid the "Invalid date" error in Visual C++ =

Article ID: 156139

Article Last Modified on 6/2/2005

-

APPLIES TO


 * Microsoft Visual C++ 4.2 Enterprise Edition
 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 4.2 Professional Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q156139



SUMMARY
If you run a SQL Server stored procedure that has a datetime type parameter, you need to provide the value in a specific format or you get the following error:

22008[Microsoft][ODBC SQL Server Driver]Invalid date

Visual C++, Enterprise Edition, version 5.0 can also give "Invalid timestamp" error for some combination of date and time formats.



MORE INFORMATION
  Create the following stored procedure in a SQL Server datasource:      CREATE PROCEDURE GetDateTime @dt datetime AS      RETURN   Execute the Stored Procedure.   The "Execute Stored Procedure" window asks for parameters. The following are the only acceptable formats:

yyyy-mm-dd yyyy-mm-dd hh:mm:ss All other formats generate the above error message. 

Keywords: kberrmsg kbhowto kbinfo kbsqlprog kbdatabase kbprogramming kbeedition KB156139

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.