SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 SSIS Date format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ugh3012
Yak Posting Veteran

62 Posts

Posted - 07/15/2013 :  13:45:08  Show Profile  Reply with Quote
I have a SQL statement that takes the date format from 2011-03-01 00:00:00 to 03/01/2011. If I preview it in SSIS or run the DQL in MS SQL, it shows the correct date format. However, when I run it in SSIS to put the SQL result set to flat file, it puts it back to 2011-03-01 00:00:00. Why is it doing that? I have three tables and each have columns with date in it. All are working fine except for one. What am I missing?

ugh3012
Yak Posting Veteran

62 Posts

Posted - 07/15/2013 :  14:09:15  Show Profile  Reply with Quote
If I take out the field and replace it with this.

Select '03/01/2011' As dateStrTest from ...

it still returns 2011-03-01 00:00:00 in the flat file. I suspect it is the connection manger, but I am not sure what is causing that.
Go to Top of Page

ugh3012
Yak Posting Veteran

62 Posts

Posted - 07/15/2013 :  16:19:00  Show Profile  Reply with Quote
I found the problem. It was set to datetime in metadat, the area where you double click on the green arrow that is pointed to Flat File Destination. I could not figure out how to change it, so I deleted the OLE Source and put in a new one and this time I had the correct SQL syntax, so it recognized it as a string, not datetime.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 07/16/2013 :  01:03:27  Show Profile  Reply with Quote
Unless there's a business case, dont change date formats. Keeping them in native formats means you'll have less issues while using them for manipulations later. Otherwise you'll still need some logic to convert it back to datetime for comparison, sorting etc. This will have an issue especially when format is date is ambiguos.
See below post for more details

http://visakhm.blogspot.com/2011/12/why-iso-format-is-recommended-while.html

However if file is just send to user for display without any further manipulation, then you may be fine with it.


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000