Problem with dates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • php newbie

    Problem with dates

    Hello,

    I am trying to insert some date values into a table. I am using ODBC
    prepared statements to (potentially) improve performance. The
    statement syntax I am using is this:

    INSERT INTO date_tests (date_col) VALUES ( CONVERT(DATETIM E, ?, 121) )

    The table is defined as "CREATE TABLE date_tests (date_col DATETIME)".
    Then, I call this prepared statement in a loop to insert some date
    values from an array. The values in the array look like this:
    "1994-05-14 11:00:00:000" They are all valid dates and conform to the
    ODBC date style supported by Sqlserver.

    But I get the following error: [Microsoft][ODBC SQL Server
    Driver]Optional feature not implemented.

    I have tried different date formats and date values; but each time I
    get the same error message. What is interesting is that if I use
    straight "INSERT INTO " statements and not use a prepared statement,
    there is no problem.

    Will appreciate any suggestions and ideas to resolve this.
  • John Bell

    #2
    Re: Problem with dates

    Hi

    Using the style parameter in the CONVERT function when converting to
    datatime is not a documented option.

    From BOL:
    style

    Is the style of date format used to convert datetime or smalldatetime data
    to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data
    types), or the string format when converting float, real, money, or
    smallmoney data to character data (nchar, nvarchar, char, varchar, nchar, or
    nvarchar data types).



    John

    "php newbie" <newtophp2000@y ahoo.com> wrote in message
    news:124f428e.0 407121442.70ceb 5ae@posting.goo gle.com...[color=blue]
    > Hello,
    >
    > I am trying to insert some date values into a table. I am using ODBC
    > prepared statements to (potentially) improve performance. The
    > statement syntax I am using is this:
    >
    > INSERT INTO date_tests (date_col) VALUES ( CONVERT(DATETIM E, ?, 121) )
    >
    > The table is defined as "CREATE TABLE date_tests (date_col DATETIME)".
    > Then, I call this prepared statement in a loop to insert some date
    > values from an array. The values in the array look like this:
    > "1994-05-14 11:00:00:000" They are all valid dates and conform to the
    > ODBC date style supported by Sqlserver.
    >
    > But I get the following error: [Microsoft][ODBC SQL Server
    > Driver]Optional feature not implemented.
    >
    > I have tried different date formats and date values; but each time I
    > get the same error message. What is interesting is that if I use
    > straight "INSERT INTO " statements and not use a prepared statement,
    > there is no problem.
    >
    > Will appreciate any suggestions and ideas to resolve this.[/color]


    Comment

    Working...