MS SQL

SQL Server CONVERT() Function

Convert() function used to convert one data type to another datatype, be used to display date/time data in various formats

Syntax

-- CONVERT Syntax:  
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )  

Arguments:

data_type | Refer the which datatype what to be convert.

( length ) | Refer the length of the new data type.

expression | Refer the source datatype which one you want convert.

style | Refer the specifies how the CONVERT function will translate expression

Example

SELECT CONVERT(Varchar(20),GETDATE(),20) AS [YYYY-MM-DD hh:mm:ss]   

Thank You

Leave a Reply

Prabhakaran Jayaraman