4 New T-SQL Functions: Listing 1.

Using TRY_CONVERT with the Style parameter.

select TRY_CONVERT(varchar(50), '08/18/2012', 1) as NewResult
NewResult
09/08/12

select TRY_CONVERT(varchar(50), '08/18/2012', 2) as NewResult
NewResult
12.09.08

select TRY_CONVERT(varchar(50), '08/18/2012', 3) as NewResult
NewResult
08/09/12

select TRY_CONVERT(varchar(50), '08/18/2012', 4) as NewResult
NewResult
08.09.12

select TRY_CONVERT(varchar(50), '08/18/2012', 5) as NewResult
NewResult
08-09-12

About the Author

Sam Nasr has been a software developer since 1995, focusing mostly on Microsoft technologies. Having achieved multiple certifications from Microsoft (MCAD, MCTS(MOSS), and MCT), Sam develops, teaches, and tours the country to present various topics in .Net Framework. He is also actively involved with the Cleveland C#/VB.Net User Group, where he has been the group leader since 2003. In addition, he also started the Cleveland WPF Users Group in June 2009, and the Cleveland .Net Study Group in August 2009, and is the INETA mentor for Ohio. When not coding, Sam loves spending time with his family and friends or volunteering at his local church. He can be reached by email at sam@nasr.info.