﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / date problem in flat source / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 02:09:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>bitbucket is the hero here, and well done with the example.And by the way do not hesitate to ask questions as needed in the future.  There is help hereM.</description><pubDate>Thu, 21 Feb 2013 14:05:02 GMT</pubDate><dc:creator>Miles Neale</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>Guys, you are my heroes of the day. It now works.. so far, let's hope it keeps going like that !Thank you very much, I will probably need your help again, so keep coming around sometimes :-P</description><pubDate>Thu, 21 Feb 2013 13:52:00 GMT</pubDate><dc:creator>kanoe82</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>Thanks for your help.I understand your solution, but I have 4 sources that I have to join, so there's a lot of datas, not just 3 or 4. With your solution, I have to do value by value ans that is not possible.Is this possible to make it automatic after the extraction and before the loading?</description><pubDate>Thu, 21 Feb 2013 13:17:03 GMT</pubDate><dc:creator>kanoe82</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>HERE  it is from a table (Now I used a temporary table BUT ONLY for illustration IN your situation it would be the real table)[code="sql"]   /* I used a temporary table BUT ONLY for illustration        the values I used are from your posting Posted Today @ 6:13 AM  */   CREATE TABLE #T (D VARCHAR(20))   INSERT INTO #T(D)     VALUES ('01/12/2012'),('03/Dec/2012'),('01/01/13')   SELECT D as 'Input value', CAST(D AS DATE) AS 'Output' FROM #TResultsInput value                       Output01/12/2012                  2012-01-1203/Dec/2012                 2012-12-0301/01/13	            2013-01-01[/code]With your new data:[code="sql"]  CREATE TABLE #T (D VARCHAR(20))   INSERT INTO #T(D)   VALUES ('01/12/2012'),('03/Dec/2012'),('01/01/13')   INSERT INTO #T(D)   VALUES ('04/01/2013 15:02'),('21/Dec/12 2:17 PM')   SELECT D as 'Input value', CAST(D AS DATETIME) AS 'Output' FROM #TResults:Input value	          Output01/12/2012	         2012-01-12 00:00:00.00003/Dec/2012              2012-12-03 00:00:00.00001/01/13                 2013-01-01 00:00:00.00004/01/2013 15:02         2013-04-01 15:02:00.00021/Dec/12 2:17 PM        2012-12-21 14:17:00.000[/code] I hope this assists you.  If NOT please post why not and maybe someone can assist you further.</description><pubDate>Thu, 21 Feb 2013 13:05:46 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>If you want to include the time with the date use the DATETIME function in the CAST instead of DATE.Also What is suggested is not to just convert the three dates used in the example but that you populate a temporary table and use that as input to cast datetime formats of the input to the common format you want.</description><pubDate>Thu, 21 Feb 2013 12:45:50 GMT</pubDate><dc:creator>Miles Neale</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>Thanks all for your help unitl so far.So, I tried your solution David but it didn't work. Or I didn't make it work I don't know :hehe:This is a sample of the data in the source 04/01/2013 15:0204/01/2013 15:4221/Dec/12 2:17 PM02/01/2013 14:3021/Dec/12 1:04 PM04/01/2013 13:4621/Dec/12 5:46 PMI don't know how to convert the hour, so still with a derived column, I just kept the date. Now I'm trying to convert it as dd/mm/yyyy...@bitbucket-25253I have a lot of datas, not juste 3, and I have to do an automatic task, so I don't think your solution is fine for this problem. But thank you :)By the way, sorry for my poor english :)</description><pubDate>Thu, 21 Feb 2013 12:24:11 GMT</pubDate><dc:creator>kanoe82</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>If you import the data into a staging table, you could then execute: [code="sql"]   DECLARE @D1 VARCHAR(20)   DECLARE @D2 VARCHAR(20)   DECLARE @D3 VARCHAR(20)   SET @D1 = '01/12/2012'   SET @D2 = '03/Dec/2012'   SET @D3 = '01/01/13'   SELECT CAST(@D1 AS DATE) AS 'was (dd/mm/yyyy)',CAST(@D2 AS DATE)    AS 'was (dd/mmm/yyyy)' ,CAST(@D3 AS DATE) AS 'was (dd/mm/yy'Result:was (dd/mm/yyyy)	was (dd/mmm/yyyy)	was (dd/mm/yy)2012-01-12	         2012-12-03	           2013-01-01[/code]</description><pubDate>Thu, 21 Feb 2013 11:07:20 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>Kanoe - did you get this working yet?</description><pubDate>Thu, 21 Feb 2013 10:22:44 GMT</pubDate><dc:creator>Miles Neale</dc:creator></item><item><title>RE: date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>If all the input dates are valid dates in the format DMY then use a derived column as you stated but cast the input to date (proving your output table is expecting this)Try something like(DT_DBDATE)[Column 0]in the expression for the derived column</description><pubDate>Thu, 21 Feb 2013 07:40:08 GMT</pubDate><dc:creator>David Burrows</dc:creator></item><item><title>date problem in flat source</title><link>http://www.sqlservercentral.com/Forums/Topic1422494-1292-1.aspx</link><description>Hello everyone,So I really am a newbie and I have a flat source ( csv file ) with some dates. But all the dates don't have the same formats. For exemple :01/12/2012 (dd/mm/yyyy)03/Dec/2012 (dd/mmm/yyyy)01/01/13 (dd/mm/yy)I have to convert the dates to the same format ( dd-mm-yyyy) with SSIS but I really don't know how. I used a derived colum to change mmm into mm with a replace function.  but I don't know if it's a good solution to my problem. Any ideas please ?Thank you for your time anyway :)</description><pubDate>Thu, 21 Feb 2013 04:13:44 GMT</pubDate><dc:creator>kanoe82</dc:creator></item></channel></rss>