select CONVERT(varchar(10), getDate(),120) --不要时间2002-1-1
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108) ---06:05:05
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108) ---06:05:05
Select Convert(varChar(22),getdate(),20)以'\'分隔:
Select Convert(varChar(22),getdate(),131)(2003-07-11 11:11:05.243) =>(2003-07-11 11:11:05.000)
Select Cast(Convert(varChar(19),getdate(),20) as DateTime)
select @aset @a='2004-01-01'
select @aset @a='2005/1/1'
select @aset @a='20060101'
select @a都是对的关键是外面要有'号
declare @a datetime
select @a='2003-01-01'
,@a='2003/01/01'
,@a='2003.01.01'
,@a='2003 01 01'结果都是一样的