mm-dd-yyyy hh:mm:ss in excel destination using ssis

Tadishetty, Sandeep 101 Reputation points
2021-03-09T00:38:53.203+00:00

Hi,

I am trying to extract the data from SQL table with datetime as datatype to excel sheet and I need the data in excel sheet as mm/dd/yyyy hh:mm:ss. Please let me know the solution since I am getting text format in excel column as yyyy-mm-dd hh:mm:ss instead of mm/dd/yyyy hh:mm:ss format.

SQL Source:

75604-image.png

Data I need in Excel Destination:

75615-image.png

I extracted data but got the wrong format in excel sheet:

75605-image.png

Thanks,
Sandeep

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

Accepted answer
  1. Yitzhak Khabinsky 24,926 Reputation points
    2021-03-09T14:00:37.287+00:00

    Hi @Tadishetty, Sandeep ,

    MS Excel has no notion of data types. It a virtual electronic "paper" that accepts any scribbles.
    Each Excel cell has two things:

    • raw data
    • formatting

    So you need to keep raw data in SSIS as DATETIME format yyyy-mm-dd hh:mm:ss based on ISO 8601 standard. After that switch to Excel and format relevant cells column via a custom format for human eyes.

    What will it do? Exactly as I explained above. Excel will keep raw data as is, and custom formatting will present it as asked by a custom formatting. Such setup will allow date and time operations in Excel.

    Please see below how it looks in Excel.

    75874-excel-cell-formatting.png


1 additional answer

Sort by: Most helpful
  1. Monalv-MSFT 5,891 Reputation points
    2021-03-09T03:28:39.96+00:00

    Hi @Tadishetty, Sandeep ,

    We can use Data Conversion and Derived Column in ssis Data Flow Task.

    Please refer to the following pictures:

    1. 75672-dataconversion.png
    2. 75608-derivedcolumn.png
      TOKEN((DT_WSTR,50)Date1," ",1) + " " + TOKEN((DT_WSTR,50)Date1," ",2)
    3. 75681-exceldata.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.