Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Date format in SSIS export

Author  Topic 

littlewing
Starting Member

33 Posts

Posted - 2009-06-04 : 11:11:28
I have a table where I have CreatedDate(datetime)column. A typical date looks like 22/08/2005 1:59:43 PM

I am trying to export the rows to a text file using SSIS. I need the exported date to be in the format mm/dd/yyyy so in my source SQL command I run CONVERT(VARCHAR(10), c.CreatedDate, 101) AS 'CreatedDate' which returns the format required.

However CreatedDate is getting written as 2005-08-22 00:00:00 in my text file. My SSIS column is defined as date [DT_DATE] and I've tried DT-STR as well.

Can someone provide me with the correct way of doing this? Should I use a Derived Column? Can someone provide the correct DateConversion expression if so?

Thanks in advance.
LW

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-04 : 13:11:07
if you're using CONVERT(VARCHAR(10), c.CreatedDate, 101) as expression it should come as DT_STR. did you try refreshing metadata to see if it correctly picks up datatype?
Go to Top of Page

littlewing
Starting Member

33 Posts

Posted - 2009-06-04 : 15:00:14
I changed the column to DT_STR, resaved, but the MetaData still shows the CreatedDate as DT_DBTIMESTAMP. This is from the "Source Component" OLE DB Source, the package still assumes it to be a date I gather.

"Name" "Data Type" "Precision" "Scale" "Length" "Code Page" "Sort Key Position" "Comparison Flags" "Source Component"
"CreatedDate" "DT_DBTIMESTAMP" "0" "0" "0" "0" "0" "" "OLE DB Source"

Can I force that to be DT_STR in the Metadata?

Thanks,
LW
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-09 : 13:40:05
did you try refreshing metadata? if it still doesnt work, use a data conversion task for that
Go to Top of Page

sudevpdas
Starting Member

1 Post

Posted - 2010-01-22 : 08:54:45
Hi...
I faced the same problem. you will need to change the datatype of the Datefield in the Advanced editor to String and try mapping the same to the destination and see the metadata .it should work

Go to Top of Page
   

- Advertisement -