I have dates in a column of database but the date format is not same. Some are mm-dd-yyyy and some are mm.dd.yy or other. How do I format it into same type using a query?
I am using SQL Server 2008.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
My recommendation would be:
Add a column of type
DATEto your table:Update your table to convert those
varcharvalues toDATE:Drop that old column:
From now on – use the new
DATEcolumn exclusively.You can format it to any string representation that is supported in SQL Server using the
CONVERTfunctionOnce you have that
DATEcolumn, you can output it in whatever string formatting you need:gives you: