sql server中datetime字段去除时间的语句

时间:2022-06-02 00:25:43

selectCONVERT(varchar,getdate(),120)

2004-09-1211:06:08

selectreplace(replace(replace(CONVERT(varchar,getdate(),120),\'-\',\'\'),\'\',\'\'),\':\',\'\')

20040912110608

selectCONVERT(varchar(12),getdate(),111)

2004/09/12

selectCONVERT(varchar(12),getdate(),112)

20040912

selectCONVERT(varchar(12),getdate(),102)

2004.09.12

selectCONVERT(varchar(12),getdate(),101)

09/12/2004

selectCONVERT(varchar(12),getdate(),103)

12/09/2004

selectCONVERT(varchar(12),getdate(),104)

12.09.2004

selectCONVERT(varchar(12),getdate(),105)

12-09-2004

selectCONVERT(varchar(12),getdate(),106)

12092004

selectCONVERT(varchar(12),getdate(),107)

0912,2004

selectCONVERT(varchar(12),getdate(),108)

11:06:08

selectCONVERT(varchar(12),getdate(),109)

091220041

selectCONVERT(varchar(12),getdate(),110)

09-12-2004

selectCONVERT(varchar(12),getdate(),113)

120920041

selectCONVERT(varchar(12),getdate(),114)

11:06:08.177

selectCONVERT(varchar(10),getdate(),120)