how to convert odbc db time field to datatime

  • Hi,

    I have to pull the data from ODBC db, and they have a field call eventtime and that field have a data type Time, when I am importing into SQL it will give me different numbers, that field have data like 12:20:00, 12:35:00 but when I import the data I am getting 819000000000, i try to import into char, varchar,number data type but can't get what I want like datetime e.g 2009-14-08 08:50:55.654

    thanks for you help

  • How do you pull the data? Where are you pulling it from? What is the data type of the original source?

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Hi,

    i am pulling one of our vender and using ODBC drive and they have a data store on they db and have a field datatype Time

  • use CONVER(VARCHAR,fieldname,109)

    -lk

  • You have to understand that the more details that you write, the more chances are that someone will be able to help you. Currently all we know is that you are using ODBC driver to pull data from some data source. We have no idea what this data source is (SQL Server? Oracle? DB2? Etc’). We have no idea how you are trying to get the data (You have an application that you wrote? One of the wizards? SSIS package? Linked server? Etc’). We have no idea about the format that the data is stored at the source of the information. Without knowing all of this information, I don’t think that anyone will be able to give you a valid answer.

    One thing that you did write is that is that this is from one of your vendors. Could you try and ask them how to get this data out of the database?

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • still getting same results

    0

    9000000000

    18000000000

    27000000000

    36000000000

    45000000000

    54000000000

    I save this field as varchar.

  • They store the data into they ODBC database, I their data filed type is Time and I am using import export utility in SQL 2005, I am storing the data into the table with field datatype chr,varchar,number but still not getting time like 10:15:000,10:30.987 etc I am getting all numbers like 202525522,246546854 etc

  • ODBC is not a database. ODBC is a standard for database access. There is an ODBC driver that can be used to any database that supports this standard (SQL Server, Oracle, DB2, etc’). It seems to me that data type in your source table is not a datetime. It might be something like number of minutes or seconds that past since a specific point of time, and the application that uses this information calculates the date. Can you connect your vendor and ask him about the data type of this data and how to get it as datetime?

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • The data type on my vender database is Time, they do not know how to convert into a datetime.

    they are storing the data my very min

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply