CONVERT(data_type,expression[,style])
convert(varchar(10),字段名,转换格式)
说明:
此样式一般在时间类型(datetime,smalldatetime)与字符串类型(nchar,nvarchar,char,varchar)
相互转换的时候才用到.
语句 结果
SELECT CONVERT(varchar(100), GETDATE(), 0) 07 15 2009 4:06PM SELECT CONVERT(varchar(100), GETDATE(), 1) 07/15/09 SELECT CONVERT(varchar(100), GETDATE(), 2) 09.07.15 SELECT CONVERT(varchar(100), GETDATE(), 3) 15/07/09 SELECT CONVERT(varchar(100), GETDATE(), 4) 15.07.09 SELECT CONVERT(varchar(100), GETDATE(), 5) 15-07-09 SELECT CONVERT(varchar(100), GETDATE(), 6) 15 07 09 SELECT CONVERT(varchar(100), GETDATE(), 7) 07 15, 09 SELECT CONVERT(varchar(100), GETDATE(), 8) 16:06:26 SELECT CONVERT(varchar(100), GETDATE(), 9) 07 15 2009 4:06:26:513PM SELECT CONVERT(varchar(100), GETDATE(), 10) 07-15-09 SELECT CONVERT(varchar(100), GETDATE(), 11) 09/07/15 SELECT CONVERT(varchar(100), GETDATE(), 12) 090715 SELECT CONVERT(varchar(100), GETDATE(), 13) 15 07 2009 16:06:26:513 SELECT CONVERT(varchar(100), GETDATE(), 14) 16:06:26:513 SELECT CONVERT(varchar(100), GETDATE(), 20) 2009-07-15 16:06:26 SELECT CONVERT(varchar(100), GETDATE(), 21) 2009-07-15 16:06:26.513 SELECT CONVERT(varchar(100), GETDATE(), 22) 07/15/09 4:06:26 PM SELECT CONVERT(varchar(100), GETDATE(), 23) 2009-07-15 SELECT CONVERT(varchar(100), GETDATE(), 24) 16:06:26 SELECT CONVERT(varchar(100), GETDATE(), 25) 2009-07-15 16:06:26.513 SELECT CONVERT(varchar(100), GETDATE(), 100) 07 15 2009 4:06PM SELECT CONVERT(varchar(100), GETDATE(), 101) 07/15/2009 SELECT CONVERT(varchar(100), GETDATE(), 102) 2009.07.15 SELECT CONVERT(varchar(100), GETDATE(), 103) 15/07/2009 SELECT CONVERT(varchar(100), GETDATE(), 104) 15.07.2009 SELECT CONVERT(varchar(100), GETDATE(), 105) 15-07-2009 SELECT CONVERT(varchar(100), GETDATE(), 106) 15 07 2009 SELECT CONVERT(varchar(100), GETDATE(), 107) 07 15, 2009 SELECT CONVERT(varchar(100), GETDATE(), 108) 16:06:26 SELECT CONVERT(varchar(100), GETDATE(), 109) 07 15 2009 4:06:26:513PM SELECT CONVERT(varchar(100), GETDATE(), 110) 07-15-2009 SELECT CONVERT(varchar(100), GETDATE(), 111) 2009/07/15 SELECT CONVERT(varchar(100), GETDATE(), 112) 20090715 SELECT CONVERT(varchar(100), GETDATE(), 113) 15 07 2009 16:06:26:513 SELECT CONVERT(varchar(100), GETDATE(), 114) 16:06:26:513 SELECT CONVERT(varchar(100), GETDATE(), 120) 2009-07-15 16:06:26 SELECT CONVERT(varchar(100), GETDATE(), 121) 2009-07-15 16:06:26.513 SELECT CONVERT(varchar(100), GETDATE(), 126) 2009-07-15T16:06:26.513 SELECT CONVERT(varchar(100), GETDATE(), 130) 23 ??? 1430 4:06:26:513PM SELECT CONVERT(varchar(100), GETDATE(), 131) 23/07/1430 4:06:26:513PM
来自:https://blog.csdn.net/luozhihuinet/article/details/78642238
标签:Convert,varchar,07,CONVERT,Datetime,Sql,100,SELECT,GETDATE From: https://www.cnblogs.com/djd66/p/16886090.html