In SQL Server, you can use the CAST()
function to convert an expression of one data type to another. This function works almost the same as the CONVERT()
function, except that the syntax is slightly different (and CAST()
doesn’t accept the style
argument).
So if you need to convert a string to a date/time value, you can use the CONVERT()
function or the CAST()
function.
And if you get an error while using those two functions, the PARSE()
function might be just what you need.
This article contains examples using the CAST()
function.