[SQL study notes] data type conversion

Two conversion methods

CAST method

CAST (data to be converted AS target data type)

CAST(GETDATE() AS varchar(10))

CONVERT method

1. Do not specify the format
CONVERT (target data type, data to be converted)

CONVERT (varchar(10),GETDATE())

2. Specify the format
CONVERT (target data type, data to be converted, Style)

CONVERT (varchar(10),GETDATE(),20)
Published 23 original articles · Like1 · Visits 20,000+

Guess you like

Origin blog.csdn.net/shenjie_xsj/article/details/105119380