CONVERT
Description
Sample Source Pattern
Syntax
CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) CAST( <source_expr> AS <target_data_type> )Examples
SELECT CONVERT(INT, '1998') as MyDateMyDate |
-------+
1998 |SELECT CAST( '1998' AS INT) as MyDate;MYDATE |
-------+
1998 |Casting date type to varchar
SELECT CONVERT(varchar, getdate(), 1) AS RESULT;RESULT |
---------+
12/08/22 |SELECT
TO_VARCHAR(CURRENT_TIMESTAMP() :: TIMESTAMP, 'mm/dd/yy') AS RESULT;RESULT |
---------+
12/08/22 |Casting date type to varchar with size
SELECT CONVERT(varchar(2), getdate(), 1) AS RESULT;RESULT |
---------+
07 |Code
Format
Code
Format
Code
Format
Related Ewis
Last updated
Was this helpful?