Grammar
CONVERT (data_type (length),data_to_be_converted,style)
data_type (length) Specifies the target data type (with optional lengths). The data_to_be_converted contains values that need to be converted. style Specifies the date/time output format.
The style value that can be used:
Find out how many of them are better to show:
Statement: Select convert (nvarchar), GETDATE (), 20) or select convert (nvarchar (+), GETDATE (), 120)
Result: 2015-09-22 01:35:33
Statement: Select convert (nvarchar), GETDATE (), 21) or select convert (nvarchar (+), GETDATE (), 121)
Results: 2015-09-22 01:35:52.833
Statement: SELECT CONVERT (nvarchar, getdate (), 23)
Results: 2015-09-22
Statement: Select convert (nvarchar), GETDATE (), 24) or select convert (nvarchar (+), GETDATE (), 108)
Result: 01:36:59
Statement: SELECT CONVERT (nvarchar, getdate (), 102)
Results: 2015.09.22
Statement: SELECT CONVERT (nvarchar, GETDATE (), 111)
Results: 2015/09/22
Statement: SELECT CONVERT (nvarchar, getdate (), 112)
Results: 20150922
The problem that is not quite clear now:
CONVERT (data_type (length),data_to_be_converted,style) Data_ Type can be other than nvarchar or varchar, and what is the reasonable value of length?
Use the SQL Server CONVERT () function