Regarding Date field

  • Hi,

    I am getting the date in flat file like this 12102009 and i want to save the date which is in datetime format in database. Here while importing into the database i am using derived column to convert the date column into datetime format.

    Can any one help me how to convert the date(12102009) into datetime format(12/10/2009) using derived column editor.

    Thanks,

    Jags

  • Is the value coming across as a string or an integer?

    I'd do string manipulation. If it is an integer convert to string, then use the substring function to parse out the 3 parts of the data and put the "/" between. Then convert the concatenated string to Date.

  • [font="Comic Sans MS"]

    Hey Jags -

    Not sure which one is your dd and which one is mm from your example 😛

    Anyway here you go:

    (DT_DBTIMESTAMP)(SUBSTRING((DT_WSTR,8)MyStringDate,1,4) +

    "/" + SUBSTRING((DT_WSTR,8)MyStringDate,5,2)

    + "/" + SUBSTRING((DT_WSTR,8)MyStringDate,7,2))

    oops: cross posted with Jack 😎 .. the code will work if it's string ... else you would need to convert ..

    [/font]

    [font="Comic Sans MS"]--
    Sabya[/font]

  • Hi,

    Thanks for your response and it is working fine. Thanks a lot.

    Thanks,

    jags

Viewing 4 posts - 1 through 3 (of 3 total)

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