Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Handle different date formats

$
0
0

We have CSV files as our data source and some files have different data formats (DD-MM-YYYY and MM-DD-YYYY)

We are using Flat File Source Editor for reading our CSV data.

After failing on multiple procedures (as source files can contain many empty fields), we had success by reading all data into a single row for processing using a Script Component. 

This works great until we parsed a source file that had a different date format which caused a failure as the DateTime.Parse method expected DD-MM-YYYY.

We have no way of finding out what format the CSV files will be.

We obviously need to know the format prior to the Script Component parsing which could fail on any record with a month value  > 12.

Our thinking is we could extract all the date values prior to the parsing and traverse the string array to see if any month value is > 12 and if so the format is MM-DD-YYYY. 

We could then swap the DD and MM values to be a consistent format for our Script Component.

We are looking for recommendations on the best way of handling this?



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>