SQL Server Date function
Definition and Usage
The CONVERT () function is a general function that converts a date to a new data type.
The CONVERT () function can display date/time data in different formats.
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:
Example
The following script uses the CONVERT () function to display different formats. We will use the GETDATE () function to get the current date/time:
CONVERT(VARCHAR( +),GETDATE())CONVERT(VARCHAR(Ten),GETDATE(), the) CONVERT(VARCHAR( One),GETDATE(),106)CONVERT(VARCHAR( -),GETDATE(),113)
Dec in - One: $PM A- in- - in Dec , in Dec - -: -:46.635
Conversion of string and date types in SQL Server