Datetime field overflow error

From: JohnD (john_nospam_at_tech-testing.com)
Date: 02/02/05


Date: Wed, 02 Feb 2005 01:45:30 GMT

Hello,

I'm using SQL Server 2000 with ODBC and am having difficulty binding the
appropriate type for use with a datetime column in the database. I have
the requirement that I need to have the milliseconds available to my code.

I've reduced my error to this overly simplified testcase:

The column in the database is defined as a "datetime 8".

/* Code ... */
TIMESTAMP_STRUCT data;

data.year = 1992;
data.month = 8;
data.day = 12;
data.hour = 7;
data.minute = 9;
data.second = 51;
data.fraction = 500;
SQLINTEGER ind = 0;
        
SQLRETURN rc = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT,

                                 SQL_C_TYPE_TIMESTAMP,
                                 SQL_TYPE_TIMESTAMP,
                                (SQLUINTEGER)sizeof(TIMESTAMP_STRUCT),
                                 0,
                                (SQLPOINTER)&data,
                                sizeof(TIMESTAMP_STRUCT),
                                (SQLINTEGER*)&ind);

/* End Code ... */

Calling SQLExecute returns the 'Datetime field overflow' error.

I know I'm not fully understanding something, but I cannot seem to find
an appropriate explanation for where I am going wrong.

Any assistance is greatly appreciated.

Thanks,
John



Relevant Pages

  • Re: selecting records based on the position in the database
    ... >You have a date time stamp field? ... >ORDER BY dateTime DESC; ... >> I need to write a query for a database that needs to ...
    (microsoft.public.access.queries)
  • Re: Time data type
    ... >>If I create stored procedure and add parameter of datetime data type, ... >>What is the best vay, to store the time in sql database, which data type ... > handle the formatting - after all, the presentation layer is aware of the ...
    (microsoft.public.sqlserver.programming)
  • RE: Record order in an mdb database
    ... The clustered key will set up physical ... > I'm using an Access type database to store data that is logged> automatically by another program eg every 10 minutes of every day. ... The> timestamp is included as a datetime field in every record and is> assigned as the primary key. ... > sequence of database records. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Application wont run in the US
    ... if the connection is closed when you fire the query. ... > program is raising major errors that seem to involve the database. ... > able to replicate the bug by temporarily switching a UK-locale PC to ... Of course as soon as I mention datetime, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: De-Nullifying Columns?
    ... I'd try to convince the higher-ups not to do this. ... key referencing something else, you simply won't be able to do this without ... when 'datetime' then castas sql_variant) ... >database and the columns from each table (unless someone can point me ...
    (microsoft.public.sqlserver.programming)