T-SQL 101: 81 Applying styles while using CONVERT
In a previous post about CAST and CONVERT, I mentioned that when you use CAST, you don’t get the option to specify the format you want to use. SQL Server offers an extension to the SQL standard with CONVERT and it lets you do just that.
CONVERT has an option parameter that lets you apply a style to the data type conversion that you’re doing.
In the example shown above, I’m converting the current date and time (based upon the SYSDATETIME() function) to a varchar(8), using style 112.
2021-01-18