Data conversion for DateTime column from excel to SQL in SSIS

Tadishetty, Sandeep 101 Reputation points
2021-03-10T02:56:11.787+00:00

Hi,

I am trying to load data from excel source where the date column has data like "Sun Mar 07 00:17:07 PST 2021" and I need to load it to SQL table with date time data type and my value supposed to be in following format mm/dd/yyyy hh:mm:ss. Please let me know the solution.

Excel Source Data:

Sun Mar 07 00:17:07 PST 2021

SQL Destination Table with datetime column:

mm/dd/yyyy hh:mm:ss

Thanks,
Sandeep

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,452 questions
0 comments No comments
{count} votes

Accepted answer
  1. Monalv-MSFT 5,891 Reputation points
    2021-03-10T07:46:18.15+00:00

    Hi @Tadishetty, Sandeep ,

    We can use Derived Column and Data Conversion in ssis package.

    Please refer to the following pictures:
    76110-df.png

    76148-excelsource.png

    76167-derivedcolumn.png
    Expression:
    (DT_WSTR,10)(TOKEN(Col1," ",2) == "Jan" ? 1 : (TOKEN(Col1," ",2) == "Feb" ? 2 : (TOKEN(Col1," ",2) == "Mar" ? 3 : (TOKEN(Col1," ",2) == "Apr" ? 4 : (TOKEN(Col1," ",2) == "May" ? 5 : (TOKEN(Col1," ",2) == "Jun" ? 6 : (TOKEN(Col1," ",2) == "Jul" ? 7 : (TOKEN(Col1," ",2) == "Aug" ? 8 : (TOKEN(Col1," ",2) == "Sep" ? 9 : (TOKEN(Col1," ",2) == "Oct" ? 10 : (TOKEN(Col1," ",2) == "Nov" ? 11 : 12))))))))))) +"/"+(DT_WSTR,10)TOKEN(Col1," ",3) + "/" +(DT_WSTR,10)TOKEN(Col1," ",6) + " " + (DT_WSTR,10)TOKEN(Col1," ",4)

    76168-dataconversion.png

    76193-sqltable.png

    Best regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful