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. The default style when converting from the datetime and smalldatetime data types is 0 and 100 (these represent the same style). Therefore, when you don't provide a style. CONVERT(char(10), GETDATE, 112): CONVERT « Data Convert Functions « SQL Server / T-SQL Tutorial.
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.
Basic Example
The default style when converting from the datetime and smalldatetime data types is 0
and 100
(these represent the same style). Therefore, when you don't provide a style (third parameter), this is how it's styled:
Result:
Karate Kid 2010 Full Movie Download free download - SmartDraw 2010, Internet Download Manager, VisualRoute 2010, and many more programs. Karate kid 2010 movie download free. Karate Kid 2010 Full Movie Download free download, and many more programs. Film/Movie Gratis: The Karate Kid (2010) BluRay 720p 750MB,review and download new release movie on MKV, AVI, DAT, and other format from mediafire or other mirror. The Karate Kid (2010) watch full movie, online on Soap2day, watch The Karate Kid (2010) movie online, free with subtitle on Soap2day.
However, you'll get a different result if the original data type is not datetime or smalldatetime.
If you need it to be returned in a different style, you'll need to specify a third argument.
Styles with Two Digit Years
Below are examples of the various values you can use to specify the style using a two digit year component.
Styles 1 to 6
Result:
Styles 7 to 6
Result:
Convert Date 112
Styles with Four Digit Years
Below are examples of the various values you can use to specify the style using a four digit year component.
Styles 100 to 103
Result:
T Sql Convert Date 112
Styles 104 to 108
Sql Convert(varchar(20) Getdate() 112)
Result:
Styles 109 to 112
Result:
Sql Convert Date To 112
Styles 113 to 114
Result:
Styles 120 to 127
Result:
Style 130
Result:
Microsoft warns that this value does not render correctly on a default US installation of SSMS.
Style 131
Result:
You can read more about the available date/time styles on the Microsoft website.