sql server convert string to date mm dd yyyy

Posted on : 24-04-2012 | By : Devi Prasad | In : SQL Server Basics


Below script converts string(varchar) to date. Date value in string can be in the format mm/dd/yy (or) mm-dd-yyyy
SELECT CAST(’12/30/2000′ AS DATE)
–mm-dd-yyyy using cast
SELECT CAST(’12-30-2000′ AS DATE)

–mm/dd/yyyy using cast
SELECT CONVERT(date,’12/30/2000′)
–mm-dd-yyyy using cast
SELECT CONVERT(date,’12-30-2000′)

Reference : Devi Prasad (sqlserverlearner.com)

Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.

Your Ad Here

Tags: , , , ,