troubleshooting Question

Convert DateTime value

Avatar of tim_cs
tim_csFlag for United States of America asked on
Microsoft SQL Server 2005SQL
8 Comments1 Solution640 ViewsLast Modified:
I'm uploading a flat file I recieve into a temp table.  A date in the file is in the format of 'dd-mm-yy' and is placed into a varchar field in the temp table.  Is the only way to convert this to an actual date in SQL by using SUBSTRING like below or is there a better way?  This is for SQL 2005.  

CAST(SUBSTRING(F1,4,2) + '-' + SUBSTRING(F1,1,2) + '-' + SUBSTRING(F1,7,2) AS datetime)

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros