The CONVERT()
function allows you to convert between data types. It’s similar to the CAST()
function, but one of the benefits of CONVERT()
is that, when you convert from a date/time data type to a string, you can add an optional argument that specifies the style that you want the return value to be in. For example, you can have it returned as dd.mm.yyyy, yyyy-mm-dd, dd mon yyyy, etc
This article contains examples of the various styles you can return when converting a date/time value to a string using the CONVERT()
function in SQL Server.