Skip to content
+1-888-319-3663

COMMUNITY FORUM

Whats the right way for importing dates ?

Mike Tsui asked 1 year ago
I have source file using YYYYMMDD as date from a CSV file,  sql is expecting YYYY-MM-DD.    Whats the best way to import this correctly into sql ?  pretask or use calculated in column type or something else ?  
Answers
Patrick Roth Staff answered 1 year ago
You would want to use a calculation of some sort.
Either a “Date” calculation
https://www.eonesolutions.com/Manuals/SmartConnect/SmartConnect%202016/?page=sc_date_column
or you could code it yourself
https://www.eonesolutions.com/discussion/problem-with-dates-odbc-source/
How you manipulate the field depends more on how SC is reading the field.  Is it coming in as a string?  The date calculation works really nicely for that.
If it comes in as an actual “date” field then the scripting method such as the 2nd forum post would work nicely.
 
Mike Tsui answered 1 year ago
Its a csv file, so apparently I read it wrong,  it was YYYYDDMM and I can’t directly import it into a date column since sql did not know that format.   As of now, I import it as a string and use sql substring task to rebuild it as YYYY-MM-DD into a formatted date column.   Ill try the calculation method you mention.  
Thanks for the info

If you would like to submit an answer or comment, please sign in to the eOne portal.