HOWTO: Use the SQL Server DateTime Parameter

ID: Q156139


The information in this article applies to:
  • Microsoft Visual C++, 32-bit Editions, versions 4.2, 5.0, 6.0


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

  1. Create the following stored procedure in a SQL Server datasource:
    
          CREATE PROCEDURE GetDateTime @dt datetime AS
          RETURN 


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


Additional query words:

Keywords : kberrmsg kbprg kbEEdition kbMFC kbVC kbVC420 kbVC500 kbVC600
Version : 4.2 5.0 6.0
Platform : NT WINDOWS
Issue type : kbhowto


Last Reviewed: July 29, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.