Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. problem with conversion of a char data type to a datetime data type

problem with conversion of a char data type to a datetime data type

Scheduled Pinned Locked Moved Database
helpdatabasesql-serverquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Payal_e_m
    wrote on last edited by
    #1

    Hi, I am working with an SSIS package(2005), which dumps records from a csv file into TABLE1. After making some alterations to thses records, it is gain inserted into another TABLE2 in the DB. One of the columns is a date column. TABLE2 has all the datatypes fixed and it has a col with datatype "smalldatetime". TABLE1 is created each time the package is run. So at first i made the TABLE1.Rdate col datatype datetime but when i try converting this col to smalldatetime for inserting into TABLE2 it gives an error "The conversion of a datetime data type to a smalldatetime data type resulted in an out-of-range datetime value." I tried changing the date col datatype to VARCHAR but again at the time of converting this col to smalldatetime for inserting into TABLE2 it gives an error "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.". The date in the TABLE1.Rdate col is in the format '2009-10-13'. Can anyone help me with this Please? Thanks & regards, Payal

    M 1 Reply Last reply
    0
    • P Payal_e_m

      Hi, I am working with an SSIS package(2005), which dumps records from a csv file into TABLE1. After making some alterations to thses records, it is gain inserted into another TABLE2 in the DB. One of the columns is a date column. TABLE2 has all the datatypes fixed and it has a col with datatype "smalldatetime". TABLE1 is created each time the package is run. So at first i made the TABLE1.Rdate col datatype datetime but when i try converting this col to smalldatetime for inserting into TABLE2 it gives an error "The conversion of a datetime data type to a smalldatetime data type resulted in an out-of-range datetime value." I tried changing the date col datatype to VARCHAR but again at the time of converting this col to smalldatetime for inserting into TABLE2 it gives an error "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.". The date in the TABLE1.Rdate col is in the format '2009-10-13'. Can anyone help me with this Please? Thanks & regards, Payal

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I always just chuck everything into a varchar field when using SSIS and let the down stream stored proc do all the transforms. I can deal with problems better in a stored proc than insinde an SSIS package. Look in BOL for CONVERT and use one of the modifiers, 111 - Japan looks like the most likely

      CONVERT(DATETIME, varcharfield,111)

      Never underestimate the power of human stupidity RAH

      P 1 Reply Last reply
      0
      • M Mycroft Holmes

        I always just chuck everything into a varchar field when using SSIS and let the down stream stored proc do all the transforms. I can deal with problems better in a stored proc than insinde an SSIS package. Look in BOL for CONVERT and use one of the modifiers, 111 - Japan looks like the most likely

        CONVERT(DATETIME, varcharfield,111)

        Never underestimate the power of human stupidity RAH

        P Offline
        P Offline
        Payal_e_m
        wrote on last edited by
        #3

        Thank you Holmes.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups