Determine the Date Format Style and/or Type

I have encountered an interesting situation; the text dumps being received lately have mixed date format styles/types in it; i.e. Column E Date Format is "22991231" (YYYYMMDD) and the Column S Date Format is "12/31/2299" (MM/DD/YYYY).

The YYYYMMDD format is what is expected for all date columns, as the Date Validation process runs the following code ...

CONVERT(VARCHAR,CONVERT(DATE,[TheColumnEDate],105),101)

... and the date data YYYYMMDD is converted to MM/DD/YYYY.

However the Date Validation Process Fails (Conversion failed when converting date and/or time from character string.) when the Column S Data is encountered.

Is there a way to identify the Date Format Style/Type and skip the specific date columns that do not need to be converted?
Frank BryantJOATAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Nope, as text files do not have any 'metadata' that defines the data type / style of columns, such as an .xsd file would have for XML.

So this forces the developer to ass-u-me the data type.

Who's the source of the 'text dumps being received lately'?   If it's all in your power, I'd reach out and touch them to tell them to quit changing the definition of the files without contacting you previously.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Frank BryantJOATAuthor Commented:
jimhorn,

Thanks, and you confirmed my "assumption"; unfortunately I am in the position to use "as-is".
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Good luck.  

I always use the line when estimating ETL projects, 'The more guarantees you can make about the data source, the lower my estimates are'.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.