CONVERT (varchar, GETDATE (), 120)This is a function of the MSSQL database, the function of the CONVERT function is to convert the data type. and the Convert (char (), opendate,120) You're asking is a function that formats the date field and converts it into character formatting. Next, the three parameters in your function are explained separately: 1.char (20), is the target data type and length to be converted to, here you can also use varchar (20), or varchar (10), if 20 is used, the converted string can be 20 length, If it is 10, only the first 10 digits are taken. The latter is omitted. 2.openDate, is a date field, this does not have to explain too much. 3.120, is the format of the date format encoding, in addition to 120, there are many encodings, each encoding corresponds to a conversion format,
Select CONVERT (varchar, GETDATE (), 120) 2004-09-12 11:06:08
Select replace (replace (varchar, GETDATE (), 120), \ '-\ ', \ ' \ '), \ ' \ ', \ ' \ '), \ ': \ ', \ ' \ ') 20040912110608
Select CONVERT (varchar (), GETDATE (), 111) 2004/09/12
Select CONVERT (varchar), GETDATE (), 20040912
Select CONVERT (varchar (), GETDATE (), 102) 2004.09.12
Select CONVERT (varchar), GETDATE (), 101 ) 09/12/2004
Select CONVERT (varchar (104), GETDATE (), 103) 12/09/2004
Select CONVERT (varchar), GETDATE (),) 12.09.2004
Select CONVERT (varchar), GETDATE (), 12-09-2004
Select CONVERT (varchar), GETDATE (), 106) 12 2004
Select CONVERT (varchar (11), GETDATE (), 107), 2004
Select CONVERT (varchar, GETDATE (), 108): 06:08
Select CONVERT (varchar), GETDATE (), 109) 2004 1
Select CONVERT (varchar (), GETDATE (), 110) 09-12 -2004
Select CONVERT (varchar (), GETDATE (), 113) 2004 1
Select CONVERT (varchar), GETDATE (), 114) 11:06 : 08.177
Change getdate () to the appropriate field
Date format conversions in SQL Server convert (varchar, GETDATE (), 120)