troubleshooting Question

format different sql dates into mm/dd/yyyy format

Avatar of johnnyg123
johnnyg123Flag for United States of America asked on
Microsoft SQL ServerSQL
9 Comments3 Solutions112 ViewsLast Modified:
I have an sql server 2012 order table that has dates in various formats stored in a varchar field  

here is a sample

order id
    1                     Null
    2                   12-01-2017
    3                    01/01/93
    4                    01/03/16
    5                     12/01/1999
     6                    2-2-07

trying to write a query that would "force" dates into mm/dd/yyyy format

(no year is before1990)

if the date is null would like it formatted as 01/01/1900

given the sample I would like to see

ordered  date
1               01/01/1900
2               12/01/2017
3                01/01/1993
4                01/03/2016
5                12/01/1999
6                02/02/2007
ASKER CERTIFIED SOLUTION
Dean Chafee
IT/InfoSec Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 9 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 3 Answers and 9 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