sql server convert string to date yyyymmdd

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

Share:

0


You can use cast or convert to convert string which is in yyyy/mm/dd (or) yyyy-mm-dd format to date.

Below is the script:

--yyyy/mm/dd using cast
SELECT CAST('2000/12/30' AS DATE)
--yyyy-mm-dd using cast
SELECT CAST('2000-12-30' AS DATE)

--yyyy/mm/dd using cast
SELECT CONVERT(date,'2000/12/30')
--yyyy-mm-dd using cast
SELECT CONVERT(date,'2000-12-30')
(Visited 168 times, 1 visits today)



References : Devi Prasad (sqlserverlearner.com)

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.


Do you like my blog?

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




Write a comment



Tags: , ,